Array notation design considerations: Difference between revisions

Jump to navigation Jump to search
m
 
(2 intermediate revisions by the same user not shown)
Line 66: Line 66:


Value expressions could be evaluated in the newly established namespace (similar to expressions in <syntaxhighlight lang=apl inline>:Namespace</syntaxhighlight> scripts), or in the surrounding scope (similar to inline expressions in [[wikipedia:JavaScript|JavaScript]]'s object notation). It was envisioned that a main usage of the literal notation would be to collect existing values into a namespace, and evaluating inside the new namespace would force the use of <syntaxhighlight lang=apl inline>##.</syntaxhighlight> to fetch values in the surrounding scope. In a departure from JavaScript, it was found most natural that such intermediate assignments be local to the value expression, similar to assignments in dfns. Global assignment is still available using <syntaxhighlight lang=apl inline>⎕THIS.name←value</syntaxhighlight>, just as in dfns.
Value expressions could be evaluated in the newly established namespace (similar to expressions in <syntaxhighlight lang=apl inline>:Namespace</syntaxhighlight> scripts), or in the surrounding scope (similar to inline expressions in [[wikipedia:JavaScript|JavaScript]]'s object notation). It was envisioned that a main usage of the literal notation would be to collect existing values into a namespace, and evaluating inside the new namespace would force the use of <syntaxhighlight lang=apl inline>##.</syntaxhighlight> to fetch values in the surrounding scope. In a departure from JavaScript, it was found most natural that such intermediate assignments be local to the value expression, similar to assignments in dfns. Global assignment is still available using <syntaxhighlight lang=apl inline>⎕THIS.name←value</syntaxhighlight>, just as in dfns.
After publication of the formal proposal,<ref name=formprop/> Peter Mikkelsen, a then recently hired [[Dyalog Ltd]] employee<ref>[[Dyalog Ltd]]. [https://www.dyalog.com/meet-team-dyalog.htm#Peter Meet Teem Dyalog: Peter]. Retrieved May 2nd, 2023.</ref>, pointed out an inconsistency between value expressions in namespace and vector notation:
<syntaxhighlight lang=apl inline>g←1 ⋄ (a:g←2 ⋄ b:g)</syntaxhighlight> would make <syntaxhighlight lang=apl inline>(a:2 ⋄ b:1)</syntaxhighlight> but <syntaxhighlight lang=apl inline>g</syntaxhighlight> remains <syntaxhighlight lang=apl inline>1</syntaxhighlight>
while
<syntaxhighlight lang=apl inline>g←1 ⋄ (g←2 ⋄ g)</syntaxhighlight> would make <syntaxhighlight lang=apl inline>(2 ⋄ 2)</syntaxhighlight> updating <syntaxhighlight lang=apl inline>g</syntaxhighlight> to be <syntaxhighlight lang=apl inline>2</syntaxhighlight>.
Because of this, the specification was changed on May 5, 2023 to follow JavaScript; that assignments inside value expressions then affect the surrounding scope. Auto-localisation of temporary variables used in building the value can then be achieved by wrapping the expression in an anonymous [[dfn]].


== Timeline ==
== Timeline ==
Line 129: Line 139:
===2023===
===2023===
On April 21, 2023, Dyalog Ltd published a blog post by Morten Kromberg announcing to the [[community]] the formal proposal for an APL array notation.<ref name=formprop>Kromberg, Morten. [https://www.dyalog.com/blog/2023/04/formal-proposal-for-apl-array-notation-seeking-feedback/ Formal Proposal for APL Array Notation – Seeking Feedback]. Formal Proposal for APL Array Notation – Seeking Feedback. April 21, 2023.</ref>
On April 21, 2023, Dyalog Ltd published a blog post by Morten Kromberg announcing to the [[community]] the formal proposal for an APL array notation.<ref name=formprop>Kromberg, Morten. [https://www.dyalog.com/blog/2023/04/formal-proposal-for-apl-array-notation-seeking-feedback/ Formal Proposal for APL Array Notation – Seeking Feedback]. Formal Proposal for APL Array Notation – Seeking Feedback. April 21, 2023.</ref>
On May 5, 2023, the specification for scoping in namespaces was changed due to feedback from Dyalog Ltd employee Peter Mikkelsen. Assignments inside value expressions would now affect the surrounding scope rather than having [[dfn]]-like auto-localisation, which can instead be achieved by wrapping the expression in an anonymous dfn.


{{Template:Comparison of array notations}}
{{Template:Comparison of array notations}}

Navigation menu