top | item 44136357

(no title)

samth | 9 months ago

No, macros and eval are quite different. You can see this for example in Python or JavaScript, which have eval but not macros.

discuss

order

Y_Y|9 months ago

You can make macros in Python: https://github.com/lihaoyi/macropy (note that that project was started for a class taught by Sussman)

There's also a PEP to make them first-class: https://peps.python.org/pep-0638/

sparkie|9 months ago

That's a different meaning of first-class from Strachey's definition of a first-class citizen[1] - ie, one that can be passed as an argument, returned from a function, or assigned to a variable.

Syntactic macros are still second-class, like Lisp macros, but an improvement over text-replacement style macros.

For something macro-like which is first-class, there are fexprs[2] and operatives (from Kernel[3]) - these receive their operands verbatim, like macros, so they don't require quotation if we want to suppress evaluation. fexprs/Operatives can be passed around like any other value at runtime.

[1]:https://en.wikipedia.org/wiki/First-class_citizen

[2]:https://en.wikipedia.org/wiki/Fexpr

[3]:https://web.cs.wpi.edu/~jshutt/kernel.html

matheusmoreira|9 months ago

They aren't that different. Fexprs are essentially additional eval cases.