Comment

Comment by kazinator

I also don't see a nice way to implement something like with-slots as a fexpr. This relies on symbol-macrolet.

  (with-slots (a b c) obj
    ;; a b c refer to slots (assignable!)
    )
This has to evaluate obj to some hidden variable #:obj, and then replaces all occurrences of a, b, c with (slot-value #:obj 'a), etc.

I don't see how the fexpr can do that without performing the same replacement.

a, b and c are not lexical variables you can just bind and then evaluate the body. They are aliases: assigning to a sets slot a of the object.

One way is for the fexpr to contain its own eval implementation which takes an extra macro environment, indicating that when a, b and c are seen, alternative forms are to be evaluated in their place.

That just adds up to an inefficient implementation of symbol macros.

Also, how are places implemented. In particular, user-defined places. How can we have a set of fexprs like setf, push, incf, ... which can work with with arbitrary syntax denoting a place, including application-defined places.

parent kazinator 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton