New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native classes inheritance #631

Closed
iliakan opened this Issue Jul 5, 2016 · 6 comments

Comments

Projects
None yet
4 participants
@iliakan

iliakan commented Jul 5, 2016

The class semantic assumes that for class B extends A:

B.prototype.__proto__ === A.prototype // true (for method inheritance)
B.__proto__ === A // true (for static inheritance)

But for built-in classes only the 1st is true:

Array.prototype.__proto__ === Object.prototype // true

The second is wrong: Array.__proto__ !== Object.

Was that discussed and left "as is" for backwards compatibility? That's inconsistent.

@domenic

This comment has been minimized.

Show comment
Hide comment
@domenic

domenic Jul 5, 2016

Member

class A is different from class A extends Object.

Member

domenic commented Jul 5, 2016

class A is different from class A extends Object.

@getify

This comment has been minimized.

Show comment
Hide comment
@getify

getify Jul 5, 2016

Contributor

Yeah, isn't Array.__proto__ (and A.__proto__ by default) gonna be Function instead of Object?

Contributor

getify commented Jul 5, 2016

Yeah, isn't Array.__proto__ (and A.__proto__ by default) gonna be Function instead of Object?

@iliakan

This comment has been minimized.

Show comment
Hide comment
@iliakan

iliakan Jul 5, 2016

@domenic do I get it right that Array is meant to inherit from Object? Aren't they supposed to be native classes with inheritance?

iliakan commented Jul 5, 2016

@domenic do I get it right that Array is meant to inherit from Object? Aren't they supposed to be native classes with inheritance?

@iliakan

This comment has been minimized.

Show comment
Hide comment
@iliakan

iliakan Jul 5, 2016

@domenic I mean, what you say is correct now, right, that's also what I write, but from OOP standpoint that looks strange, usually classes inherit from base Object.

iliakan commented Jul 5, 2016

@domenic I mean, what you say is correct now, right, that's also what I write, but from OOP standpoint that looks strange, usually classes inherit from base Object.

@ljharb

This comment has been minimized.

Show comment
Hide comment
@ljharb

ljharb Jul 5, 2016

Member

@iliakan a "class" produces a constructor function. Functions inherit from Function.

Member

ljharb commented Jul 5, 2016

@iliakan a "class" produces a constructor function. Functions inherit from Function.

@domenic

This comment has been minimized.

Show comment
Hide comment
@domenic

domenic Jul 5, 2016

Member

Array is not meant to inherit from Object. It is a built-in class without inheritance, just like class A {} is a non-built-in class without inheritance.

Member

domenic commented Jul 5, 2016

Array is not meant to inherit from Object. It is a built-in class without inheritance, just like class A {} is a non-built-in class without inheritance.

@iliakan iliakan closed this Jul 5, 2016

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