"Bill Page" <[EMAIL PROTECTED]> writes: | On Sun, May 11, 2008 at 12:47 PM, Martin Rubey wrote: | > | > ... Moreover, what should | > | > j: Integer := 0 | > for i in 1..5 repeat | > j: Integer := i^2 | > output(j::OutputForm)$OutputPackage | > | > output? | | I would expect 0.
100% agreed -- though I don't know whether the change made that possible. (the environment structure is one of the most inadequate possible to properly handle scopes). | > It would be different from | > | > j: Integer := 0 | > for i in 1..5 repeat | > j := i^2 | > output(j::OutputForm)$OutputPackage | > | | Yes. Aagin agreed. | > but I think the intention is unclear when these semantics | > are used. | > In my mind, there is no slight amount of ambiguity about what those two constructs should be. | I think the intention is clear in languages that follow nested lexical | (static) scoping rules. | | http://c2.com/cgi/wiki?LexicalScoping | http://en.wikipedia.org/wiki/Scope_(programming) | | I suppose the question is whether it is "natural" that 'for' and other | ways for forming program blocks should establish a new lexical scope. | This is common in other languages, so I think "yes". But perhaps you | already noticed that this is *not* the case in Aldor (**): | | http://www.aldor.org/docs/aldorug.pdf#page=115 | | "New scopes in Aldor are introduced by the following expressions: | | - E where Definitions | - +-> | - with | - add | - for i in ... | - Applications, e.g. Record(i: Integer == 12) | | These forms may be nested to any depth. Note that the last two bind | names in particular positions in the expression, and **do not form | general scope levels**. Note that in Aldor, you have two more constructs: * free: you use this to prevent the Aldor compiler from making the declaration/definition local by instructing it to match it with a declaration in enclosing scope. I do not seem to see where the reference manual says what happens when there is no enclosing declaration. (Perhaps an error? A silent promotion?) * fluid: you use this to prevent the Aldor compilet from making the declaration/definition local; the variable becomes dynamic. | Lexical scoping implies that the only variables visible at a given | point in a program are those that have been created locally or | imported into scopes surrounding the current point." -- Gaby ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ open-axiom-devel mailing list open-axiom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/open-axiom-devel