april icon indicating copy to clipboard operation
april copied to clipboard

question: selective assignment (with a commute on the left)

Open justin2004 opened this issue 1 year ago • 2 comments

Selective assignment (with replicate on the left) works as expected (in April and Dyalog):

  d←'bob'
  (1 0 0/d)←'B'
  d
Bob

But the same thing (though expressed with a commute) does not in Dyalog:

  d←'bob'
  (d/⍨1 0 0)←'B'
SYNTAX ERROR
  (d/⍨1 0 0)←'B'
            ∧

and in April:

The value
  #:G2102
is not of type
  LIST
   [Condition of type TYPE-ERROR] 

The limitation in Dyalog is discussed here but I was wondering if April needs to have this limitation?

It sounds like the Dyalog limitation is expressed in terms of tokens as B Wilson says "the name to be assigned must be the rightmost token in the overall left expression." But if the validation was done later in the interpretation process (perhaps once you have a parse tree) then it it could noticed that, when a commute occurs, the textual rightmost token might not be the same as the logical rightmost token.

justin2004 avatar Dec 29 '24 13:12 justin2004

Interesting idea, I could probably register that given how I compose the assign-by-select syntax. I'll give it a try.

phantomics avatar Jan 06 '25 18:01 phantomics

@phantomics cool! I'll be interested to hear if the April approach can handle arbitrarily nested commutes. Seems like if you are using the parse tree then it would be possible.

justin2004 avatar Jan 07 '25 18:01 justin2004