selective assignement doubt

General APL language issues

selective assignement doubt

Postby gumont68 on Wed Jan 25, 2023 2:26 pm

Hi, I have a doubt here:

x←0 0 0
b←1 0 1
(b/x)y←(3 4)5
SYNTAX ERROR
but
((b/x))y←(3 4)5
works
I don't understand why we need the second set of brackets. please enlighten me, thank you :)
gumont68
 
Posts: 4
Joined: Fri Oct 19, 2018 10:22 am

Re: selective assignement doubt

Postby Phil Last on Wed Jan 25, 2023 7:07 pm

I should say that it's quite simply a bug.
User avatar
Phil Last
 
Posts: 624
Joined: Thu Jun 18, 2009 6:29 pm
Location: Wessex

Re: selective assignement doubt

Postby Phil Last on Wed Jan 25, 2023 7:11 pm

Although you'll find plenty of folks who'd say you should need parens about the entire left hand side
      ((b/x)y)←(3 4)5
User avatar
Phil Last
 
Posts: 624
Joined: Thu Jun 18, 2009 6:29 pm
Location: Wessex

Re: selective assignement doubt

Postby gumont68 on Thu Jan 26, 2023 8:27 am

Thank you Phil for you answer.
I agree that the need of extra brakets could be a bug.
But having brakets around the whole expression gives yu a value error if y is not already existing:
((b/x)y)←(4 5)10
VALUE ERROR: Undefined name: y
((b/x)y)←(4 5)10
This to me looks fine, because I guess that having y in brakets forces the interpeter to evaluate it before assigning a new value.
gumont68
 
Posts: 4
Joined: Fri Oct 19, 2018 10:22 am

Re: selective assignement doubt

Postby Phil Last on Thu Jan 26, 2023 10:32 am

I think you are being generous in giving Dyalog a nice excuse for this.

I suspect that both problems are merely holes in the testing regime that just happen to have been overlooked because of a lack of necessity or invention by developers and users in the time since development and implementation respectively - or, if ever these expessions worked, since the bugs were introduced.

There seems to be nothing in the documentation that should prohibit their evaluation.
User avatar
Phil Last
 
Posts: 624
Joined: Thu Jun 18, 2009 6:29 pm
Location: Wessex

Re: selective assignement doubt

Postby Morten|Dyalog on Wed Feb 01, 2023 12:43 pm

We have attempted to document the various forms of assignment that are supported by Dyalog APL. To summarise:

  • Plain e.g name←value
  • Distributed e.g. (name1 name2)←value and (but not recommended) name1 name2←value
  • Selective e.g. (1 0 1/name)←1 2
  • Indexed e.g. name[index]←value
  • Modified e.g. name+←value
  • Selective Modified e.g. (⊃name)+←value
  • Indexed Modified e.g. name[index]+←value
I think your example is an a combination of Distributed and Selective assignment, which is not fully supported. Some cases will work due to insufficient syntax checking in the interpreter. Note that adding parentheses is not guaranteed to make things better, in some cases it has the opposite effect, as in:

Code: Select all
      i←2
      x←0 0 0
      x[i] y←3 4
⍝ But:
      (x[i] y)←3 4
SYNTAX ERROR
      (x[i]y)←3 4
       ∧
User avatar
Morten|Dyalog
 
Posts: 451
Joined: Tue Sep 09, 2008 3:52 pm


Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest