Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a with-slots macro #118

Open
porky11 opened this issue Sep 21, 2016 · 6 comments
Open

Add a with-slots macro #118

porky11 opened this issue Sep 21, 2016 · 6 comments

Comments

@porky11
Copy link
Contributor

porky11 commented Sep 21, 2016

Something like this

(with-slots (a (b c)) x
  …)

should expand to this

(let ((a \ (: x a))
        (b \ (: x c)))
  …)

(like in CL)

@porky11
Copy link
Contributor Author

porky11 commented Oct 3, 2016

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) …))

tomhrr added a commit that referenced this issue Oct 22, 2016
@tomhrr
Copy link
Owner

tomhrr commented Oct 22, 2016

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 8648e76, though, if you want to use it in your own code.

@porky11
Copy link
Contributor Author

porky11 commented Oct 24, 2016

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

@tomhrr
Copy link
Owner

tomhrr commented Oct 24, 2016

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?

@porky11
Copy link
Contributor Author

porky11 commented Oct 25, 2016

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)

@porky11
Copy link
Contributor Author

porky11 commented Nov 1, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants