Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] context of a function Re:(5)

From: galtbarber:mailandnews at: 22-Aug-2000 16:39

Brian, /local revelation! Thanks! So, you really can see that when invoked, /local is normally set to none, and all "optional switch params" following it, up to the next /switch if any, are set to none also. Somehow I never realized that MULTIPLE parameters can follow a /switch in the function definition so I thought that /local was doing something special allowing multiples, and that it had to come last. So, you could use any [parma parmb /local x /morefrickinlocals s t u] and s t u are locals that are just every bit as good as /local, and it doesn't even matter if /local is the last switch, right? The only limit is that all real params have to come before the first /switch. What did this save RT? Did they get to avoid having to use 'use inside the function to create a separate context frame with the locals local? Since they had to support the /switches anyway and they had a mechanism for that, why not bag the extra 'use and stick the locals as "unused" switch parms? was their thinking, I suppose. The one change they had to make to accept this is that /local unused switch params (local vars) are set to none like any other unused switch parms (since /local itself is not usually invoked) This is different than simply returning false when queried with value? which is how a 'use context works and how you treat global variables as well. So then locals became initialized to none rather than simply being unset values. This is kind of amusing:
>> g: func [][probe local ] >> g
** Script Error: local has no value. ** Where: probe local
>> g: function [][][probe local ] >> g
none == none
-Galt p.s. Andrew, do you think of the processor for make object! [ a: blah b: blahblah ] as another dialect? That argument seems a teensy bit stronger than function-as-dialect, but what do I know?