Skip to content
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

Reified classes #3368

Closed
DartBot opened this issue Jun 3, 2012 · 4 comments
Closed

Reified classes #3368

DartBot opened this issue Jun 3, 2012 · 4 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). type-enhancement A request for a change that isn't a bug
Milestone

Comments

@DartBot
Copy link

DartBot commented Jun 3, 2012

This issue was originally filed by [email protected]


What steps will reproduce the problem?

The class of an object is not accessible what leads to some shortcomings when implementing the operator == in a class hierarchy (please correct me if I am wrong). For example the following code is rather repetitive and error prone:

class A {
  var a;
  operator == (other) => other is A && a == other.a;
}

class B extends A {
  var b;
  // alternatively we could call super, but that would do unnecessary class checks
  operator == (other) => other is B && a == other.a && b == other.b;
}

class C extends B {
  // alternatively we could call super, but that would do unnecessary class checks
  operator == (other) => other is C && a == other.a && b == other.b;
}

What is the expected output? What do you see instead?

class A {
  var a;
  // access to a comparable class object would simplify the code
  operator == (other) => this.class == other.class && a == other.a;
}

class B extends A {
  var b;
  operator == (other) => super == other && b == other.b;
}

class C extends B {
  // no necessary to implement operator == here
}

What version of the product are you using? On what operating system?

Dart SDK version 7904

@madsager
Copy link
Contributor

madsager commented Jun 4, 2012

Added Area-Language, Triaged labels.

@gbracha
Copy link
Contributor

gbracha commented Jun 6, 2012

Set owner to @gbracha.
Added Accepted label.

@gbracha
Copy link
Contributor

gbracha commented Jun 6, 2012

I'm renaming this to cover the issue more generally than just the use in equality functions.


Removed Type-Defect label.
Added Type-Enhancement label.
Changed the title to: "Reified classes".

@gbracha
Copy link
Contributor

gbracha commented Jun 27, 2012

It's in the 0.11 spec. Basic idea is that there will be a method on object (probably called type) that produces a suitable token representing the runtime class of the object. The name of a class or type parameter will also serve such a token when used as an expression.

Detailed proposal to be made available soon.


Added this to the M1 milestone.
Added Done label.

@DartBot DartBot added Type-Enhancement area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Jun 27, 2012
@DartBot DartBot added this to the M1 milestone Jun 27, 2012
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants