'superclass' behaves differently in class and instance #518

Closed
bronson opened this Issue Jun 16, 2011 · 3 comments

Comments

Projects
None yet
3 participants
@bronson
Contributor

bronson commented Jun 16, 2011

The superclass property/method is inconsistent: in a class it's a property that contains the superclass, in an instance it's a method that calls the superclass's method of the same name.

One = SC.Object.extend({one: 1});
a_one = One.create();

One.superclass        # returns SC.Object, One's superclass
a_one.superclass()    # inside a method, calls that method on the superclass.

This seems unnecessarily confusing.

Apologies if I got anything wrong, I'm just trying to understand http://docs.sproutcore.com/?#doc=SC.Object&method=superclass&src=false

@publickeating

This comment has been minimized.

Show comment Hide comment
@publickeating

publickeating Apr 2, 2013

Member

I've always used sc_super(), so I'm not really sure about this method. Since Safari 2, the apparent browser that can't use this, is essentially non-existent anymore, maybe we can start using this function instead of sc_super. If that is the case, I would want to rename it.

Member

publickeating commented Apr 2, 2013

I've always used sc_super(), so I'm not really sure about this method. Since Safari 2, the apparent browser that can't use this, is essentially non-existent anymore, maybe we can start using this function instead of sc_super. If that is the case, I would want to rename it.

@dcporter

This comment has been minimized.

Show comment Hide comment
@dcporter

dcporter Apr 5, 2013

Member

@mauritslamers and I have been discussing related behavior. Apparently ES5 or something no longer supports arguments.callee in strict mode, which could be a consideration in the future. Also I've never been a fan of the string replacement that sc_super entails. It's a weird requirement for the build tools.

The trouble is that without arguments.callee, there is no way for the function to endogenously access itself, right? How does the superclass method accomplish this?

Anyway, assuming that's the case, then the developer will have to refer to it by name on the superclass... which is potentially fragile and mildly annoying, but is it a big deal? Please discuss amongst yourselves.

At any rate, agreed that the behavior of superclass should be consistentified.

Member

dcporter commented Apr 5, 2013

@mauritslamers and I have been discussing related behavior. Apparently ES5 or something no longer supports arguments.callee in strict mode, which could be a consideration in the future. Also I've never been a fan of the string replacement that sc_super entails. It's a weird requirement for the build tools.

The trouble is that without arguments.callee, there is no way for the function to endogenously access itself, right? How does the superclass method accomplish this?

Anyway, assuming that's the case, then the developer will have to refer to it by name on the superclass... which is potentially fragile and mildly annoying, but is it a big deal? Please discuss amongst yourselves.

At any rate, agreed that the behavior of superclass should be consistentified.

@publickeating publickeating modified the milestones: 2.0.0, 1.11.0 Apr 30, 2014

@dcporter

This comment has been minimized.

Show comment Hide comment
@dcporter

dcporter May 23, 2014

Member

Alright the whole point of SC.Object#superclass was to allow use of SC without the build tools, which I think is an old, broken dream. Not only that, but it appears that superclass is inferior to sc_super(); in that it requires the developer to know and pass the arguments individually. I'm going to deprecate the instance method for 1.11.

Member

dcporter commented May 23, 2014

Alright the whole point of SC.Object#superclass was to allow use of SC without the build tools, which I think is an old, broken dream. Not only that, but it appears that superclass is inferior to sc_super(); in that it requires the developer to know and pass the arguments individually. I'm going to deprecate the instance method for 1.11.

@dcporter dcporter closed this in bd34254 May 23, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment