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 %%local-alias #106

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

jpellegrini
Copy link
Contributor

@egallesio this is a work in progress. I am including it here just so you can see it, but I suppose its not yet time to accept it.

This is the idea I was talking about in issue #55 .
It was actually not complex at all. With %%local-alias, it would be possible to implement hygienic macros in a clean and not complex way.

(%%local-alias b a) defines b as an alias to the a variable visible where the %%local-alias is used. It does so by pushing one more item onto the env stack: instead of a variable name (symbol), it pushes a list (the alias). The rest of the code is adapted to cope with this.

@jpellegrini
Copy link
Contributor Author

For full compliance with the standards, it would also be necessary to have a similar %syntax-alias.

> (define-syntax let (syntax-rules () ((let a b c) (+ a b c))))
> (let 2 3 4)
9

(All the issues with variables arise with syntax too, but the solution then is very similar. Working on it)

This is useful to implement hygienic macros.
@jpellegrini
Copy link
Contributor Author

This PR needs a complete rewrite -- I'll do that later when we have lexically-scoped define-macro

@lassik
Copy link
Contributor

lassik commented Oct 22, 2020

Please note that SRFI 212: Aliases is currently in draft status. Possibly related, or STklos might have some ideas that are good to add to that SRFI.

@jpellegrini
Copy link
Contributor Author

Please note that SRFI 212: Aliases is currently in draft status. Possibly related, or STklos might have some ideas that are good to add to that SRFI.

Yes - but it would make more sense to implement that after the work on lexically-scoped macros is done, because both variables and macros could have their names aliased (indeed, my idea was to use both in order to implement R7RS semantics for syntax-rules).

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

Successfully merging this pull request may close these issues.

None yet

2 participants