From: Isaac Gouy Date: 2005-12-28T04:07:54+09:00 Subject: Re: Diff of opinion on dynamic stuff Bob Hutchison wrote: > On Dec 23, 2005, at 12:47 AM, Isaac Gouy wrote: > > > Yes, the equivalent of "method_missing" has been used for many things > > in Smalltalk. Glorifying in how we can hack "doesNotUnderstand:" > > avoids having to admit that there's been a problem with the language. > > The problem being: in Smalltalk the language there is no explicit way > in the language to add a method to a class at runtime? Adding a method to a class at runtime is trivial, simply send the message "compile: aMethodSourceString" to the class. Integer compile: 'plus: anInteger ^self + anInteger' afaict Over the years Smalltalk has accumulated a bunch of really clever programming techniques to work-around the lack of meta protocols for controlling message passing. afaict CLOS provides directly what Smalltalk can only accomplish indirectly - so we should celebrate "doesNotUnderstand:" trickery as clever programming rather than clever language design. > > Maybe so, but the Smalltalk *environment* allows the programmer to do > exactly the same thing as the browser or debugger at runtime (though > only on a class level). In some implementations, there is a method > that changes an object's class, and that combined with the ability to > create a new class at runtime... (well, this is hard to manage, and > some implementations will, effectively, only redefine the parent > class of an object). This excessive use/dependency on > doesNotUnderstand is not necessary in Smalltalk. > > Isn't re-opening a class very similar to some of the better methods > in the paper below? At the very least, the associated problems are > similar :-) > > What are the Python folks doing as an alternative? > > > > > "This comparison highlights that the most commonly used technique > > based > > on the specialization of the doesNotUnderstand: method is not the best > > one. As a first explanation of this situation, one should note that > > the > > ability to directly execute a method has only lately been > > introduced in > > the interpreters (methods valueWithReceiver:arguments: on > > CompiledMethod class in VisualWorks and > > executeWithReceiver:andArguments: in IBM Smalltalk). Moreover, this > > comparison shows that the techniques based on VM lookup method or > > method wrappers should be considered by more programmers than it is > > currently the case." > > > > "Evaluating Message Passing Control Techniques in Smalltalk" > > http://www.iam.unibe.ch/~scg/Archive/Papers/ > > Duca99aMsgPassingControl.pdf > > ---- > Bob Hutchison -- blogs at > Recursive Design Inc. -- > Raconteur --