[racket] Structs and syntax-local-value ... how is the struct name overloaded? (Greg Hendershott)
On Mon, Jan 20, 2014 at 6:31 PM, Scott Klarenbach <scott at pointyhat.ca> wrote:
>> If/when it does matter, instead you could use a hashtable on the side,
>> mapping from the procedure to the info. Of course that way, you need
>> to use `(lookup thing)` to get the info.
>
>
> Not to mention that it's vastly simpler to do it this way. You get a
> straightforward transformer proc and a hashtable bound as syntax.
>
> This is partly a learning exercise for me - so it's valuable to go through -
> but the more I look at it the more I think it's a lot of complexity just to
> be able to overload the struct name, when it would suffice for match and
> other macros that wanted compile-time meta info to follow a convention like
> struct-name-META or something. Afterall, structs already come with a lot of
> magical bindings that you have to learn by convention, what's one more?
That convention wouldn't work for a lot of important use cases. For
example, if you use `rename-in` or `rename-out` with a struct name,
`match` and everything else still works. In general, conventions like
the one you suggest quickly become very painful to work with.
Instead, what we've learned over the years is that making everything
(or almost everything) follow the binding structure of the program
works much better.
Sam