Remix.run Logo
meken 2 hours ago

> To anticipate a common question: why couldn't my-unless be a function? Function arguments are evaluated eagerly, before the function ever sees them.

Interesting, so if you’re using a lazy language then you don’t need a macro here and could write my-unless as a function.

floxy 10 minutes ago | parent | next [-]

Or you could wrap arguments in lambdas (anonymous functions) for eagerly-evaluted languages. Lisp unfortunately has a bulky syntax for lambdas, compared to something like Smalltalk. Of course, you can fix this with reader macros in Common Lisp (but no one does). Clojure has a shorter syntax I believe as well: #().

phyzix5761 17 minutes ago | parent | prev | next [-]

You could do that as well with lisp by passing around lambdas to functions but that adds unnecessary syntax.

wk_end 2 hours ago | parent | prev | next [-]

Indeed:

https://hackage-content.haskell.org/package/base-4.22.0.0/do...

brabel 2 hours ago | parent | prev [-]

Yes, the D language has that as a feature in function arguments!

https://dlang.org/articles/lazy-evaluation.html

It makes it hard to know when things run. In Lisp you also have that problem everywhere, of course.

As the post shows this allows you to do stuff that looks like extending the syntax of the language.

I can’t decide if I love it or hate it!