by ddragon · 6y ago · 0 comments
[1] https://en.wikipedia.org/wiki/Racket_features#Language_Exten...
It's not a direct comparison of course (nor it is a Lisp), but here is an example of linear optimization in a library that uses macros to make it a DSL closer to the description (in Julia @ before a name means it's macro, so it's easy to see) and one that uses methods:
https://nbviewer.jupyter.org/github/jump-dev/JuMPTutorials.j...
https://www.cvxpy.org/examples/basic/linear_program.html
If in the Julia example they if @variable was a function, then x >= 0 would have been evaluated immediately and it would fail since x was not defined (and if it was x >= 0 would return a boolean). To emulate that you'd probably have to pass a string "x >= 0", which the function would then have to parse (it would be a DSL as well, but one you're writing from scratch), the difference here is that you can just use the language parser directly and compile already with the result.
No comments yet.