[dojo-contributors] dojo.lang.inherits

Scott J. Miles sjmiles at turbophp.com
Thu Apr 6 18:58:36 EDT 2006


>> To call delegation the method of inheritance in JS is not an inaccurate
statement <<
 
I agree with that. It's just that IMO it is not a good name for what
function-currently-known-as-dojo.lang.inherits does.
 
I understand what you all are saying about being careful about terms-of-art,
esp. when they express specific concepts in other languages, but I think we
are putting too fine a point on it. 
 
>> Seriously though, this is one of the reasons why I was making the
argument yesterday; it seems like there's a lot of people who come from
C++/Java/C# backgrounds (not you, I've no idea what yours is) that think
there should be a way of calling a super method in JS and get really
frustrated when you can't.  And we can't really think about it the way C#
does (I think that's what Bill was referring to); that's similar but not the
same thing.  <<
 
Seems like maybe this is a different issue, with respect to calling super
methods. I know you know this, but to be clear for the record, you can of
course call a super method. In JS you can call absolutely any function in
the context of any given object. But whatever you call it, it's convenient
to clone-and-extend-prototypes. That's why we have a handy method for it.
It's also and useful to be able to reference methods from other places in
the prototype chain (most often, from the immediate ancestor). If we can
make that handier, that's valuable IMO. 
 
I don't think forcing users to understand language details "for their own
good" makes much sense: aren't we trying to make JS more pleasant?
 
And just to be clear: I think JS is cool, and I'm certainly not advocating
some kind of 'let's make it work like C++' solution. Regarding my
background, I've used many, many languages. Probably more C/C++/ObjectPascal
than anything else, but I don't think I have any particular bias (well, I
kinda like Prolog, and I kinda don't like Java ... it's younger than I am,
and too wordy).
 
Regards,
Scott J. Miles
TurboAjax Group
http://www.turboajax.com
 
________________________________

From: dojo-contributors-bounces at dojotoolkit.org
[mailto:dojo-contributors-bounces at dojotoolkit.org] On Behalf Of Tom Trenka
Sent: Thursday, April 06, 2006 2:47 PM
To: dojo dev.
Subject: Re: [dojo-contributors] dojo.lang.inherits


Funny how?  Do I amuse you? Am I like a clown to you?

:D

OK, enough of the bad mafia jokes...so the key to JS is that the prototype,
and searching through the prototype chain to find the first method or
property signature (depending on scope definition) is what passes for
inheritance in JS.  To call delegation the method of inheritance in JS is
not an inaccurate statement (although it's deceptive), and that's one of the
reasons (making assumptions in Alex's thinking here that might be wrong)
Alex called it "delegate". 

Seriously though, this is one of the reasons why I was making the argument
yesterday; it seems like there's a lot of people who come from C++/Java/C#
backgrounds (not you, I've no idea what yours is) that think there should be
a way of calling a super method in JS and get really frustrated when you
can't.  And we can't really think about it the way C# does (I think that's
what Bill was referring to); that's similar but not the same thing. 

trt



On 4/6/06, Scott J. Miles <sjmiles at turbophp.com> wrote: 

	First off, to rebut my comment with 'delegation is inheritance' is
just kind of funny. =P
	 
	My training is such that delegation refers to locating a method call
implementation at run-time on an object. The system of locating a particular
method through a prototype chain may be called delegation, but the process
of construcing a new object type by creating a new link in a prototype
chain, adding or overriding properties, and managing initialization is
something greater. 
	 
	If you wanted to rename dojo.event.connect to dojo.event.delegate, I
would say that is clearly correct. IMO, dojo.lang.inherits is
JavaScript-style inheritence. 
	 
	If you want to call it cloneAndExtend or something, I can't argue,
but it seems like pedantry. 
		 
	Regards,
	Scott J. Miles
	TurboAjax Group
	http://www.turboajax.com
	
	________________________________

	From: dojo-contributors-bounces at dojotoolkit.org
[mailto:dojo-contributors-bounces at dojotoolkit.org] On Behalf Of Tom Trenka
	Sent: Thursday, April 06, 2006 11:11 AM
	
	To: dojo dev.
	Subject: Re: [dojo-contributors] dojo.lang.inherits
	

		Scott--
	What are you referring to, Sandro's link or JS?  Delegation *is* the
inheritance model in JS, that's what the prototype system implements...
	
	trt
	
	
	On 4/6/06, Scott J. Miles <sjmiles at turbophp.com> wrote: 

		IMO, what we have here is a type of mass delegation,
potentially an entire
		interface's worth. Additionally, where the new object does
not contain a new
		implementation of a method, it acquires the superclass
method (or any 
		property). Overall, I would say this is more generally an
inheritence
		operation.
		
		Regards,
		Scott J. Miles
		TurboAjax Group
		http://www.turboajax.com
		
		-----Original Message----- 
		From: dojo-contributors-bounces at dojotoolkit.org
		[mailto: dojo-contributors-bounces at dojotoolkit.org
<mailto:dojo-contributors-bounces at dojotoolkit.org> ] On Behalf Of Sandro
Magi
		Sent: Thursday, April 06, 2006 4:43 AM
		To: dojo dev.
		Subject: Re: [dojo-contributors] dojo.lang.inherits
		
		+1 to delegate.
		
		It's closer to the proper concept.
		
		Sandro 
		
		Alex Russell wrote:
		> To address Jesse's point, how about a name like:
		>
		>       dojo.delegate(subclass, superclass, { ... });
		>
		> ?
		>
		> On Wednesday 05 April 2006 5:33 pm, Scott J. Miles wrote: 
		>> dojo.defineClass(subclass, superclass, { constructor:
..., param1:
		>> ..., func1: ... });
		>>
		>> +1
		>>

	

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.3.5/302 - Release Date: 4/5/2006
 




More information about the dojo-contributors mailing list