Hi,

> I was wondering for the longest time why doesn't Class#create have
> arguments?

Class.create does have arguments, details in the docs[1]. The
implementation doesn't use any _named_ arguments, it accesses its
arguments via the `arguments` array (on the first line of the
function, in fact).

[1] http://api.prototypejs.org/language/class.html#create-class_method

HTH,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com


On Nov 11, 12:26 am, joneff <jon...@gmail.com> wrote:
> I was wondering for the longest time why doesn't Class#create have
> arguments?
>
> I mean it's obviously to allow inheritance from multiple objects, but
> honestly, how often does this happen?
>
> Soooo.. If arguments are provided, Class#create could look like
>
> function create(parent, properties) {
>         if (typeof parent !== "function") {
>                 properties = parent;
>                 parent = null;
>         }
>
>         ... // more code
>
>         if (parent) {
>                 subclass.prototype = parent.prototype;
>                 klass.prototype = new subclass;
>                 parent.subclasses.push(klass);
>         }
>
>         if (properties)
>                 klass.addMethods(properties);
>
>         ... // more code
>
> }
>
> which avoids few function calls. More over, if indeed multiple
> inheritance is required it could be done in the addMethods method with
> looking for special key (say implements or inheritsFrim or what ever).
>
> However, typeof is kinda unfriendly looking to me. I don't know how
> many of you are using MS Client JS, but they have an extra property
> __typeName to indicate the type of object being worked with.
>
> So if there was indeed such a mechanism in Prototype, the syntax would
> become
>
> if (!parent.__typeName || parent.__typeName != "class")
>
> It is indeed longer than the first one, but looks friendlier (to me)
> and actually having an easy way to check whether or not an object is a
> class seems handy (again to me).
>
> Any thoughts?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to