29
78
Fork
You've already forked r7rs
2

Remove capture-lookup in favour of global identifier property lookup procedure #183

Merged
dpk merged 3 commits from global-id-prop-ref into main 2024年07月25日 23:51:55 +02:00
Owner
Copy link

As suggested in comment to issue 138

As suggested in [comment to issue 138](https://codeberg.org/scheme/r7rs/issues/138#issuecomment-1316814)
dpk changed title from (削除) Remove capture-lookup in favour of identifier-property-ref (削除ここまで) to Remove capture-lookup in favour of global identifier property lookup procedure 2023年11月20日 20:52:08 +01:00
Author
Owner
Copy link

@mnw: Do you have any objections to merging this?

@mnw: Do you have any objections to merging this?
Member
Copy link

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-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`.
Author
Owner
Copy link

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."

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-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." 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.)
Member
Copy link

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."

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-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.

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-environment parameter 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-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.)

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.

> > 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." > > 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-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. 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-environment` parameter 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-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.) 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.
Author
Owner
Copy link

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.

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.
Sign in to join this conversation.
No reviewers
Labels
Clear labels
Batteries
Issues for the Batteries volume of the report, providing a standard library
Cleanup
Issues where inconsistencies or other infelicities have arisen
Consent Docket
Items which will be automatically be given a certain resolution if no objection is made by a certain date
Environments
Issues for the Environments volume of the report, providing OS interfaces and similar
Foundations
Issues for the Foundations volume of the report, related to the core language semantics
Macrological Fascicle
Meta
Procedural and organisational issues
Multiple proposals exist
Multiple competing, concrete proposals to resolve this issue exist (whether they are SRFI or still only pre-SRFI)
Pie-in-the-sky ideas
Ideas currently lacking any form of worked-out proposal
Problems without solutions
Problems we *must* solve but haven’t worked out any solution for yet
Procedural Fascicle
Public Comment
Publications
Issues related to the practicalities of making the report available
Question
For information and clarification
R6RS Compatibility
Issue touches on questions of R6RS compatibility
R7RS-small
Issues with the Small language Report
Resolution in draft
A resolution (not necessarily final) is specified in the current draft of the relevant fascicle
Specification exists
Proposals for which a viable, but incomplete specification text exists
SRFI/RnRS spec exists
A SRFI for this proposal exists, or a solution from another RnRS
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
scheme/r7rs!183
Reference in a new issue
scheme/r7rs
No description provided.
Delete branch "global-id-prop-ref"

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?