about having something similar to the extend attribute ?

Peter Hall peterjoel at gmail.com
Mon Jan 8 11:00:24 PST 2007


Do you see any practical advantage of this over just using static or
package-level methods and passing an instance as an argument?

Peter

On 1/6/07, zwetan <zwetan at gmail.com> wrote:
> as seen here
> http://www.mozilla.org/js/language/js20/rationale/miscellaneous.html
>
> Class Extensions / extend Attribute
>
> "namespace StringExtension;
>
> StringExtension extend(String) function scramble():String {...}
> StringExtension extend(String) function unscramble():String {...}
>
> use namespace(StringExtension);
>
> var x:String = "abc".scramble();"
>
> would it be as much complicated to use namespace shadowing
> http://developer.mozilla.org/es4/proposals/namespace_shadowing.html
> to obtain the same kind of behaviour, simply put "add methods to a
> class defined somewhere else" ?
>
> for ex:
>
> package
> {
>         public final class String extends Object
>         {
>         ...
>         }
> }
>
> being able to define an extension like this
>
> package
> {
>         public namespace StringExtension;
>
>         StringExtension class String extends Object
>         {
>         ...
>         public function scramble():String {...}
>         public function unscramble():String {...}
>         ...
>         }
> }
>
>
> and then use it in strict mode
>
> use namespace StringExtension;
> var foobar:String = "abcdef".scramble();
>
>
> for now the only option to do that is to be in standard mode
> and add to the prototype, this is good
> but as a dev what I really want is the strict mode
> but still being able to extend such final class
> (even if that idea may raise some hairs in horror ;))
>
> zwetan
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es4-discuss
>



More information about the Es4-discuss mailing list