Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

define-macro vs syntax-rules

Name: Anonymous 2014-04-27 9:50

If a scheme implementation fully implements define-macro but leaves out syntax-rules, is anything being lost?

Name: Anonymous 2014-04-27 12:20

imma let you finish but hygiene is the best macro system ever

Name: Anonymous 2014-04-27 12:44

I wrote a MIPS assembler in scheme macros at the age of 7.

Name: Anonymous 2014-04-27 12:45

>>1
Sort of. The old style lisp macros take code and expand it to new code. Then binding to variables are evaluated after expansion, within the scope of where the code expanded. syntax-rules allows you to refer to variables that were defined in the scope of where the macros was defined. Under the hood, this feature isn't hard to provide, but it is not possible to do directly using classic macros. However, you can write a macro that takes a macro definition and a way to refer to variables in the macro's scope, and generate unique names for global variables that would then refer to these.

tldr; you can do everything with define-macro, but to get that variable capture it'll be kinda hacky.

But syntax-rules is actually weaker than define-macro, since it does everything with a pattern language rather than evaluation of lisp/scheme code. But syntax-parse from r6rs has the same power.

Name: >>4 2014-04-27 15:19

Actually it's easier in common lisp to just use packages. If you allocate a package for the macro, you can define these variables in that package. Then you don't need to worry about collisions as long as other code doesn't touch that package.

Name: Anonymous 2014-04-27 17:32

defmacro and gensym, motherfuckers

Name: Anonymous 2014-04-27 17:44

I wrote a BOGOMIPS assembler in scheme macros at the age of 6.

Name: Anonymous 2014-04-27 17:45

r6rs masterrace

Name: Anonymous 2014-04-27 18:23

I think Scala is better.

Name: Anonymous 2014-04-27 20:37

>>8
masterrace
back to the imageboards!

r6rs
heh more like R-6-R-HUGEEEEEE

Name: Anonymous 2014-04-28 0:40

Thank you for your detailed answer, >>4-san.
>>6
My thoughts exactly.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List