As suggested in comment to issue 138
Remove capture-lookup in favour of global identifier property lookup procedure #183
global-id-prop-ref into main capture-lookup in favour of identifier-property-ref (削除ここまで)capture-lookup in favour of global identifier property lookup procedure @mnw: Do you have any objections to merging this?
If you want to go this route, make identifier-property a pure procedure and define a dynamic parameter expand-environment so that looking up a property would be done by (identifier-property (expand-environment) KEY VALUE). This at least clearly separates the impure from the pure part and, moreover, allows future additions in the form of further static procedures acting on the "expand environment."
Keeping future extensions in mind, in this model, identifier-property should probably be renamed ref-property (think of set-property!). The prefix "identifier-" is too much in any case; the corresponding definition is just called define-property.
If you want to go this route, make
identifier-propertya pure procedure and define a dynamic parameterexpand-environmentso that looking up a property would be done by(identifier-property (expand-environment) KEY VALUE). This at least clearly separates the impure from the pure part and, moreover, allows future additions in the form of further static procedures acting on the "expand environment."
What would be the concrete benefit of this, other than the theoretical benefit of separating dynamic state from pure operations? (If we have other future procedures which depend on the expand environment, the same question applies to them — they could equally just use the dynamic environment directly.) When would someone, in practice, want to use identifier-property (or whatever we call it) with an argument other than a direct call to (expand-environment)? You could, in theory, save the expand environment in a variable; I don’t see any benefit in doing this other than perhaps a mild (non-asymptotic) performance improvement.
Moreover, this proposal implies too much to me about the implementation strategy for identifier properties. It is, under both the SRFI 213 and current identifier-property proposal models, possible to store identifier properties on the wrap of a syntax object. (This is perhaps not advisable, for reasons I think we’ve previously discussed, but at least it’s possible in theory.) In this case, in the SRFI 213 system, capture-lookup always passes the same static lookup procedure in; in this PR as currently stands, identifier-property is itself such a static procedure. An expander-environment parameter becomes a useless dummy in such an implementation — a sign, to me, that this is an implementation detail which we should hide.
(Moreover moreover, what if someone parameterizes expander-environment to some nonsense? This can be guarded against by making expander-environment a trivial wrapper procedure around an actual internal %expander-environment parameter object, among other possibilities, but this is just silly.)
If you want to go this route, make
identifier-propertya pure procedure and define a dynamic parameterexpand-environmentso that looking up a property would be done by(identifier-property (expand-environment) KEY VALUE). This at least clearly separates the impure from the pure part and, moreover, allows future additions in the form of further static procedures acting on the "expand environment."What would be the concrete benefit of this, other than the theoretical benefit of separating dynamic state from pure operations?
This, in itself, is an important benefit.
Moreover, this proposal implies too much to me about the implementation strategy for identifier properties. It is, under both the SRFI 213 and current
identifier-propertyproposal models, possible to store identifier properties on the wrap of a syntax object. (This is perhaps not advisable, for reasons I think we’ve previously discussed, but at least it’s possible in theory.) In this case, in the SRFI 213 system,capture-lookupalways passes the same static lookup procedure in; in this PR as currently stands,identifier-propertyis itself such a static procedure.
As you just have shown, it does not imply anything about the implementation strategy. By the way, even a model where the property is directly stored on the wrap can benefit from an extra parameter to determine whether the information in the wrap is stale (or inaccessible in the given environment).
An
expander-environmentparameter becomes a useless dummy in such an implementation — a sign, to me, that this is an implementation detail which we should hide.
Quite the contrary. expander-environment is not an implementation detail but the reification of a semantic entity. The fact that some implementations can do with a trivially expander-environment is an implementation-detail, on the other hand.
(Moreover moreover, what if someone parameterizes
expander-environmentto some nonsense? This can be guarded against by makingexpander-environmenta trivial wrapper procedure around an actual internal%expander-environmentparameter object, among other possibilities, but this is just silly.)
Sorry for the confusion here. By dynamic parameter, I didn't mean a parameter in the sense of SRFI 39, just a thunk whose value depends on the dynamical state of the expander.
I’m not convinced by the argument for (expander-environment). If a future RnRS thinks it worthwhile and has a use case for reifying the expander environment, I suggest they add it as an optional argument to identifier-property, in the same way the I/O procedures default to the dynamic values of current-{input,output}-port if no explicit port argument is given.
Racket’s expand-time values and Guile’s expand-time identifier introspection both use the dynamic environment of the expander.
No due date set.
No dependencies set.
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?