about having something similar to the extend attribute ?

zwetan zwetan at gmail.com
Sat Jan 6 11:56:43 PST 2007

as seen here

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
to obtain the same kind of behaviour, simply put "add methods to a
class defined somewhere else" ?

for ex:

	public final class String extends Object

being able to define an extension like this

        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 ;))


More information about the Es4-discuss mailing list