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

Partial classes #1810

Closed
DartBot opened this issue Feb 14, 2013 · 11 comments
Closed

Partial classes #1810

DartBot opened this issue Feb 14, 2013 · 11 comments

Comments

@DartBot
Copy link

DartBot commented Feb 14, 2013

This issue was originally filed by luciandog...@ymail.com


Please implement partial classes in Dart.

@DartBot
Copy link
Author

DartBot commented Feb 14, 2013

This comment was originally written by adrian.avil...@gmail.com


You can already split classes in Dart with part files, that would be the equivalent.

@dgrove
Copy link

dgrove commented Feb 14, 2013

Set owner to @gbracha.
Removed Type-Defect label.
Added Type-Enhancement, Area-Language, Triaged labels.

@gbracha
Copy link

gbracha commented Feb 15, 2013

We've discussed this on the mailing list. You can use parts for large libraries. You can define multiple mixins and combine them. We do not need this extra sugar.


Added AsDesigned label.

@kevmoo
Copy link
Member

kevmoo commented Mar 19, 2015

Link to misc@ discussion Jan 2013 - https://groups.google.com/a/dartlang.org/d/topic/misc/KTuJ_Z6O1oQ/discussion

Mixins are great to encourage reuse, but the there are arguments for partial classes that cannot be covered by mixins: generating code that includes constructors, for instance.

For example:

// mycode.dart
library mycode;

part 'mycode.g.dart';

class Person {
  String firstName, lastName;
}

// mycode.g.dart
part of mycode;

partial class Person {
  Person.fromJson(json) =>
    new Person()
      ..firstName = json['firstName']
      ..lastName = json['lastName'];

  toJson() => {'firstName': firstName, 'lastName': lastName};
}


Added Triaged label.

@gbracha
Copy link

gbracha commented Mar 20, 2015

Added Accepted label.

@DartBot
Copy link
Author

DartBot commented Mar 21, 2015

This comment was originally written by hangglide...@gmail.com


We donot need this extra sugar.

  • 1

@munificent munificent changed the title Please implement partial classes in DART Partial classes Dec 16, 2016
@MihaMarkic
Copy link

MihaMarkic commented May 15, 2019

Not being able to extend classes through partial implementation files is PITA and makes some scenarios really hard to achieve when it comes to autogenerated code. This is even more important to flutter because it doesn't support reflection (or whatever it's called in dart world) and you have either write or autogenerate code (i.e. json (de)serialization).
Sadly this issue isn't getting any love for more than 3 years.

@eernstg
Copy link
Member

eernstg commented May 15, 2019

You might want to check out several recent related issues: #40, #41, #42, #177, #309.

Granted, C# style partial classes are not equivalent to any of these, but they are concerned with mechanisms for extending existing classes.

@MihaMarkic
Copy link

@eernstg Thanks for the info, hopefully they will come out with something comparably useful.

@mit-mit mit-mit transferred this issue from dart-lang/sdk Aug 19, 2021
@mateusfccp
Copy link
Contributor

Now this is a duplicate of #252.

@lrhn
Copy link
Member

lrhn commented Aug 20, 2021

It is, and with that comment, there is a link from #252 to here, so let's close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants