Making "super" work outside a literal?

Mariusz Nowak medikoo+mozilla.org at medikoo.com
Tue Jun 21 01:55:47 PDT 2011




Peter Michaux wrote:
> 
> On Mon, Jun 20, 2011 at 3:23 PM, Axel Rauschmayer <axel at rauschma.de>
> wrote:
> 
>> What is the use case for sideways calls? Can you point me to an example?
> 
> You want to allow the API (a.k.a. public methods) of an object to be
> overridden, but you don't want the functionality of any non-overidden
> API methods to change. In short, you want to avoid the template
> pattern. I gave a synthetic example in the sideways calls thread I
> started.
> 

Peter,

I'm actually not sure about that. I would even say that allowing such
sideway calls within 'instance' methods would be bad hint. I wouldn't like
to approach following code, it doesn't allow to extend A the way I may need
to:

var A = function () {};
A.prototype = {
	one: function () {
		return A.prototype.two.call(this, args...);
	},
	two: function () {
		...
	}
};

If we definitely need to call A.prototype.two whether we extended A or not,
then we probably talk about 'static' method which should not be called on
instance and should be defined directly on A (or privately within closure),
then we may just call it A.two(args...). At least that's what my OOP
experience says.

I understand your example at
http://old.nabble.com/super%2C-self%2C-and-sideways---durable-vs.-template-p31830714.html
to me it's just programmer mistake that should throw error.
Maybe you're looking for some pattern that can be realized using 'static'
methods (?) but forcing or introducing such behavior somewhere close 'this'
or 'super' logic might not be what people expect. My experience is not that
vast, is there any language that provide sugar for such calls ?


-----
Mariusz Nowak

https://github.com/medikoo
-- 
View this message in context: http://old.nabble.com/Re%3A-es-discuss-Digest%2C-Vol-52%2C-Issue-117-tp31889060p31892412.html
Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at Nabble.com.



More information about the es-discuss mailing list