David wrote:
> It's interesting that there are numerous libraries available that make
> it possible to do block-scoped changes to core behavior, but no one
> ever seems to use them.  This makes me wonder whether the demand for
> selector namespaces, or some other language-level solution, is really
> all that great.

The problem with block-scoped behavior changes is that they are not 
really blocked scoped.  In other words, the changes are not limited to 
the block in which they occur, but also to any code called by the block. 
Although the change is limit in extent (i.e. the change has a beginning 
and end point in time), the scope of the change is potentially 
unlimited.

Rather selector namespaces should be lexically scoped.  In other words, 
selecting a particular selector namespace should apply to only those 
method calls lexically in the same scope.  Selector namespaces should 
give the guarantee that when I write:

  obj.some_method

I know exactly WHICH some_method gets calls (modulo normal OO method 
overriding).

A short aside:  Way back in the old days of Lisp, variables were 
dynamically bound.  That means whenever you referenced a non-local 
variable name, Lisp would search the call stack for the most recent 
definition of that variable.  It was easy to implement but turned out to 
be a bad idea in the long run.  Today, modern Lisp use lexical binding 
(with dynamic binding still available by explicit request).

Today's (misname) block scoped behavior changes act like dynamic 
binding.   I hope that the coming selector namespaces will be more like 
lexical binding.

-- Jim Weirich

-- 
Posted via http://www.ruby-forum.com/.