Fully dynamic d by opDotExp overloading
Nick Sabalausky
a at a.a
Fri Apr 17 12:07:32 PDT 2009
"bearophile" <bearophileHUGS at lycos.com> wrote in message
news:gsai34$1p9k$1 at digitalmars.com...
> 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.
Interesting, I didn't know that.
> Usually in such languages such things are less dangerous because the code
> contains lot of tests anyway.
See, that just sounds to me like the dynamic-ness is just creating extra
work for less payoff. I'd rather have my compiler automatically guarantee
correctness (when possible) than have to manually create even more tests
than I'm already creating and *hope* that they catch all the problems.
> 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.
>
That would certainly be better. It sounds very much like extension methods,
which I'm a big fan of (but I have yet to see polymorphic extension methods,
that would be nice to have). Although I think I would still prefer extension
methods (polymorphic or otherwise) be defined/declared statically.
More information about the Digitalmars-d
mailing list