Open porky11 opened 8 years ago
maybe it should not set the variables to pointers but the values, since setting multiple values of a struct is also possible using (setf struct ((a value1) (b value2) …))
Though this is useful, I'm not sure the core is the right place for it, at least at the moment. An example definition without error-checking has been added to the repository at https://github.com/tomhrr/dale/commit/8648e7670e6263bc46a7dabc372ec28323420b6e, though, if you want to use it in your own code.
I wrote some version of this myself, but I'm not sure if it's useful, when you can't use it for both getting and setting values
The definition in the repository can be used to both get and set values, because the new bindings are pointers, rather than values. Is there something about it that doesn't work as expected?
the problem if with-slots uses pointers, not values, it doesn't get that much easier: I'd still have to write (@ a)
, which is not much more than(@: x a)
, so I'm not sure, if it will be used this way.
Maybe some macros would be more useful
(some kind of read-macros may also be nice, but this should not be included in core. Dale as IR for higher level languages may be a good idea. The parser could be implemented as macro and allow some dialect of dale allowing read-macros or similar. It's easier to parse to dale code than llvm directly, so it would make a good IR I think, but this may be another issue)
another more usable solution may be something like symbol-macrolet (which works similar to mfor), so that with-slots (and also with-accessors) may work as now, only that the variables will be symbol-macros, dereferencing the pointers, which are used in the current version.
Something like this
should expand to this
(like in CL)