Fully dynamic d by opDotExp overloading

Steven Schveighoffer schveiguy at yahoo.com
Fri Apr 17 11:58:03 PDT 2009


On Fri, 17 Apr 2009 14:49:37 -0400, Yigal Chripun <yigal100 at gmail.com>  
wrote:

> On 17/04/2009 21:34, bearophile wrote:
>> Nick Sabalausky:
>>>> There are people who swear by the ability of adding methods at
>>>> runtime and changing the inheritance hierarchy dynamically. It
>>>> makes for a very fluid environment.
>>> Personally, I've always seen that as extremely sloppy and
>>> haphazard.
>>
>> Adding methods at runtime is named "monkey patching", and it is
>> considered a bad practice even in Python. In Ruby it is more common.
>> Usually in such languages such things are less dangerous because the
>> code contains lot of tests anyway. Some people say that a way to
>> remove most of the downsides of monkey patching is to make it scoped,
>> that is the changes (like a method added or replaced) to a class
>> aren't seen globally in the whole program (like from other modules),
>> but only in the scope where such change is done (and its subscopes).
>> I think I have not seen languages where this is doable yet.
>>
>> Bye, bearophile
>
> just like anything in life this can be overused. This is a very useful  
> tool in a programmer's toolbox for when you need, for example, to  
> quickly experiment with something or do an urgent fix.
>
> It's like when you build a house you have it properly designed and have  
> solid foundations but after the house is built you can still redesign  
> internally without rebuilding the entire house.

It's more like adding another outside door.  Try doing that ;)  (BTW,  
removing one is easy, but that kind of doesn't apply here...)

changing internals in code is easy, that's why we use OOP.  Changing APIs  
is not.

-Steve



More information about the Digitalmars-d mailing list