Paul_Abrahams%Wayne-MTS@UM.CC.UMICH.EDU (11/03/90)
The Icon operator ! generates a sequence of variables when it's applied to a list, string, or record. My question is: is there any way that a user-defined procedure can generate variables (other than using the "variable" function)? Here is my attempt at it; it didn't work. Paul Abrahams abrahams%wayne-mts@um.cc.umich.edu procedure main () l := [1,2,3,4] every writes(!l, " ") write() # writes 1 2 3 4 every !l := 9 every writes(!l, " ") write() # writes 9 9 9 9 every !p1(l) := 7 # produces an error; can't assign 7 to "9" every writes(!l, " ") write() end procedure p1(z) suspend !z end
cary@HPCLLAK.CUP.HP.COM (Cary Coutant) (11/03/90)
The program would have worked but for a double bang -- you applied the bang operator within the procedure, and on the procedure call. Removing the latter yields a program that does what you were expecting. -Cary Coutant, HP Computer Language Lab procedure main () l := [1,2,3,4] every writes(!l, " ") write() # writes 1 2 3 4 every !l := 9 every writes(!l, " ") write() # writes 9 9 9 9 every p1(l) := 7 # no extra bang operator here every writes(!l, " ") write() end procedure p1(z) suspend !z end