-
Notifications
You must be signed in to change notification settings - Fork 992
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
Symbol generation with lazily generated names that behave like standard symbols #909
base: main
Are you sure you want to change the base?
Conversation
This idea seems ok to me. Some thoughts on the implementation here:
For your consideration, here's what I'd do: https://github.com/mflatt/ChezScheme/tree/srfi-260. I was aiming to simplify the encoding so that the FWIW (but you may already know this): Another possible approach to |
Thank you for this thorough review and the improvements, @mflatt. I went through them and incorporated them in my pull request. I simply forgot about checking for Due to the improvements, I could apply two further simplifications. You added the "discard" flag back on It seems unfortunate that
This is how I would implement them if there were no historical baggage. As R6RS does not have |
generated symbol names
I think it would be better for Meanwhile,
I don't immediately see how this would work. My understanding so far is that the interaction below is meant to reliably produce
To make sure that |
(I meant "missing on `gensym->unique-string", of course.)
Okay, but then it would make sense to have a dedicated primitive for that purpose like
I believe you understand the intended behaviour of generated symbols correctly. My idea is the following: If When the symbol is later interned, the symbol's unique name will then be something like When a symbol with a name like The disadvantage of this approach is that it will be easy to forge given hash values. On the other hand, the symbol hash is not cryptographically secure anyway. At the moment, Maybe, if |
Agreed. It just didn't seem worth the effort of tracking down uses of
Ah, I see now. Yes, that does seem workable. |
This patch implements the
(generate-symbol [pretty-name])
procedure. As(gensym)
, it returns a symbol with a lazily generated unique name; however, the resulting symbol is not a gensym but an ordinary symbol.Such a procedure is useful in situations where it is expected that symbols are identical if and only if their names (as returned by
symbol->string
) are spelled the same.In particular, this is the case for R6RS code. Strictly speaking, by section 11.10 of the R6RS, gensyms are non-conformant. This patch improves R6RS compatibility by providing an R6RS version of
generate-temporaries
where the symbols are generated bygenerate-symbol
and not bygensym
. Moreover, ordinary symbols have write/read invariance even when only standard lexical syntax is allowed.For the context of this patch, see also SRFI 260.