> On 13 Feb 2018, at 11:32, Ben Coman <b...@openinworld.com> wrote: > > > > On 13 February 2018 at 17:25, Marcus Denker <marcus.den...@inria.fr > <mailto:marcus.den...@inria.fr>> wrote: > Sometimes I think we should treat globals more in a “late bound” fashion. > > > This may remove a big reason for needing asClass, which was introduced so you > could DoIt > on a script to load a package and then operate on a class from that package > before that class was defined. > > > e.g. right now we say that “Undeclared” vars are to be avoided at any cost. > > But we could just treat them like we treat messages that are send that do not > exist. > > Forcing “#classNamed: “ for all unknown globals is a bit similar than forcing > to use “perform:” for > all unknown selectors. > > e.g. why have Smalltalk at: #SomeClass and react to it if you could instead > reason on the fact that > a variable is not bound (yet). > > SomeGlobal ifUndefined: [ ]. > > This way we would not obscure the fact that we are accessing a global and we > model explicitly the state > if it is bound or not. > > I guess its partially a compiler issue. One way would be for the compiler to > wrap the reference > to SomeGlobal in an instance of UnknownGlobal. When a message is sent to > that instance, > it can check whether SomeGlobal is now defined (i.e. loaded earlier in the > script) and forward the message to SomeGlobal. > The current Undeclared mechanism should make it easy: for every Undeclared, we do have a binding in Undeclared that binds the name to nil. Could be another value (some first class object). Maybe it could even put as the value the binging itself, which is already a subclass of Association called UndeclaredVariable.
Marcus