jsoftware / jsource

J engine source mirror
Other
650 stars 90 forks source link

[Feature Request] Private assignment =. to scope only to containing line if used outside of explicit definition {{…}} #200

Closed cchando closed 2 weeks ago

cchando commented 2 weeks ago

The proposed change would solve the longstanding issue of local assignment not being available for tacit definitions, which causes tacit code to unavoidably pollute the global namespace when defining helper verbs. In particular, this would make local scoping for tacit verbs practical in conjunction with the addition of the proposed for line continuation.

This is in the same spirit as the different scoping of $: inside vs. outside of an explicit definition.

Currently =. has the same meaning as =: outside of explicit definitions.

HenryHRich commented 2 weeks ago

I don't understand the advantage of the proposal compared to using local names and applying f. to them when they are included in a larger definition.

Regardless of the merits, this is such a thoroughgoing incompatibility, touching user scripts and all documentation, as to be a non-starter.

Henry Rich

On Mon, Jul 8, 2024, 12:55 AM Cameron Chandoke @.***> wrote:

The proposed change would solve the longstanding issue of local assignment not being available for tacit definitions, which causes tacit code to unavoidably pollute the global namespace when defining helper verbs. In particular, this would make local scoping for tacit verbs practical in conjunction with the addition of the proposed … for line continuation.

This is in the same spirit as the different scoping of $: inside vs. outside of an explicit definition.

Currently =. has the same meaning as =: outside of explicit definitions.

— Reply to this email directly, view it on GitHub https://github.com/jsoftware/jsource/issues/200, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEKVAJ7D5FERJLTMPN4TE73ZLILU7AVCNFSM6AAAAABKQBQHXKVHI2DSMVQWIX3LMV43ASLTON2WKOZSGM4TINRSG44DQOI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

cdburke commented 2 weeks ago

Usually scripts are loaded by an explicit definition, so local definitions are local to that definition, and not global.

cchando commented 2 weeks ago

Hmm, ok. I'm surprised to hear that this would necessitate many changes to documentation besides the NuVoc page. I understand the user scripts objection. Oh well.

If anyone can help clarify for me the specific documentation (besides the NuVoc page on =.) that would hypothetically need to be changed by this, it would help me in understanding the ramifications of future feature requests, so I can avoid making unrealistic ones.

Separately, the motivation here was to be able to define helper verb f locally to a given tacit verb, and still have f available to mean something else globally. And/or have it available to mean something else locally within the definition of another tacit verb. All of this is within a single script.