about having something similar to the extend attribute ?

zwetan zwetan at gmail.com
Tue Jan 9 03:29:42 PST 2007


On 1/9/07, Peter Hall <peterjoel at gmail.com> wrote:
> Personally, I think that inheritance can be confusing enough by
> itself, in terms of making it hard to know where in the chain a method
> is defined. Allowing methods to be appended in namespaces would surely
> make that even more confusing? At least with static utils, it's
> transparent.
>

It does not change the default behaviour of inheritance,
it's like the namespace shadowing
people not aware of it will at most not notice it
people aware of it will use it for advanced setup

I don't see where could be the confusion ?


> Your use-cases don't really demonstrate any benefits that couldn't be
> achieved another way, except an aesthetic one - which is a matter of
> personal taste anyway..
>

the benefit of clean and well named API is more than just personnal taste imho


> Like you, I'd shy away from prototype hacking. I'd want my code to be
> compatible with strict mode, even if that wasn't a current
> requirement. But - for me - aggregation, inheritence and static utils
> seem to have all the bases covered.
>

I just want the best of both world

well I don't want to shy away from prototype hacking :D
the very one thing that made ES3 stand out for me is the prototype

here how I see it

with ES3, you got only buildins, no frameworks
but as you can hack the prototype, you can add functionnalities to
those buildins
and have a light kind of framework dedicated to your actual task

with ES4, same set up, only buildins (a little more than in ES3), no frameworks
you can still hack the prototype but only in standard mode

if we could have a kind of "extends attribute" with namespace shadowing
it would allow us to hack the class in strict mode
but without breaking them

some other use case:
I define a Char class almost as it was a buildin
I would like to add a toChar method to the String class

later someone else need this Char class to export to XML
because he's using WDDX
he can add the toWDDX() method to the Char class

and on...
and on...


I'm not talking about
"how that would be cool to change the toString method of the Number class"

I'm talking about
"it is more usefull to add a toHexString method to the Number class
directly than any other place"


also look at how frameworks are build in Python
and compare with Java and .NET/C#

in Python you have String extensions and nobody is shocked with that
so why should we in ES4 ?

zwetan



More information about the Es4-discuss mailing list