new C(foo: 42, bar: 10)
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
--
You received this message because you are subscribed to the Google Groups "Dart Core Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to core-dev+u...@dartlang.org.
An improved default constructor seems interesting for the case where you have lots of simple record-like types with lots of fields. They tend to be a mix of required and optional fields though. So, suppose we combine this with non-null field types? If the field is final and allows null, it's optional in the constructor. If it's final and doesn't allow null, it's required.
I ran into something vaguely similar while implementing a virtual DOM for TagTree. Every HTML element has lots of attributes. It's tedious to write all the attributes more than once, even in the skeleton DOM I wrote that was far from complete.However, in TagTree, I would have found tear-off constructors more useful. In that case I was duplicating long lists of keyword parameters in create() functions that just call constructors.So, this would *also* play well with tear off constructors. If we have nice default constructors and we can tear them off, it seems like we end up with a way to create a function that returns its parameters as a simple, immutable record object. So we get a concise way to define a schema of record objects and a collection of functions to build them, with no duplication of field names or types.
var street= new Street()
..name= "Main"
..kind= "St.";
var streetAddress=new StreetAddress()
..number= 123
..street= street;
var address = new Address()
..streetAddress = streetAddress,
..city = "Springville"
..state = "Illinois";
var street= new Street()
..name= "Main"
..kind= "St.";
var streetAddress=new StreetAddress()
..number= 123
..street= street;
return new Address()
..streetAddress = streetAddress,
..city = "Springville"
..state = "Illinois";
}Alas, we don't have required named parameters. I don't think the parameters should be positional because it would mean that order of field declarations would affect your public API.
So what happens if you initialize a not-null final field with a named parameter? Will that be disallowed?
For example, the Flutter folks, and the Dart VM team supporting them, are going to do what they need to make their product successful. We've seen the same thing in dart4web and Fletch.
...
Our task is to improve the overall language in ways that all of the implementation teams are excited about. In some ways, they're our customer. Meanwhile, they may come up with something that makes sense for them but not the other implementations. We can try to generalize it to something useful across the whole system, or help them, or let them do it on their own.
Who is product manager and/or tech lead for Dart/Dart VM in terms of work with Flutter?
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
This discussion coincides nicely with the first release of built_value.dart ... https://github.com/google/built_value.dartThere's no way to use named parameters that is as flexible and powerful as builders.For nesting, the builders need to know about nested buildable types, so they can be handled correctly. (Builders should store nested builders, not nested built values).
Here's the example from up thread:new Address()
..street = (new StreetAddress()
..number = 123
..street = (new Street()
..name = "Main"
..kind = "St."))
..city = "Springville"
..state = "Illinois";And here is what it looks like with built_value.dart. You actually have a choice about how much to nest. You can write it completely flat:new Address((b) => b..street.number = 123..street.street.name = 'Main'..street.street.kind = 'St.'..city = 'Springville'..state = 'Illinois');
var addr = Address {
street.number : 123,
street.street.name : 'Main',
street.street.kind : 'St.',
city : 'Springville',
state : 'Illinois' };
// update
addr. {
street.number: 456 }
// immutable
addr.close();
Working with data
Today’s programs are connected and trade in rich, structured data: it’s what’s on the wire, it’s what apps and services produce, manipulate and consume.
Traditional object-oriented modeling is good for many things, but in many ways it deals rather poorly with this setup: it bunches functionality strongly with the data (through encapsulation), and often relies heavily on mutation of that state. It is "behavior-centric" instead of "data-centric".
Functional programming languages are often better set up for this: data is immutable (representing information, not state), and is manipulated from the outside, using a freely growable and context-dependent set of functions, rather than a fixed set of built-in virtual methods. Let’s continue being inspired by functional languages, and in particular other languages – F#, Scala, Swift – that aim to mix functional and object-oriented concepts as smoothly as possible.
// immutableaddr.close();
I really like the idea. Actually, "new" is not necessary either. If objects start generating "fromMap"and "toMap", normal json notation can be considered as sugar for calling fromMap automatically.
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
I don't understand that. What is the challenge with "equals"?
Why can't you do
class B extends A {
final String x;
bool operator==(other) => other is B && super.==(other) && other.x == x;
}
I admit I have never done that but always assume I could
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
I'm trying to think about the root of issue. So value classes are really json (or generally data objects) schemata built in the language. This is somewhat true for all the class based languages we have. A large part of the need may be just data validation. Maps are too weak. Classes are too clunky. This seems to be one of the issues, that Dart trying to solve, by introducing optional typing. For primitives the fix is easy. "var" and "int" works pretty well, since they are exchangeable. But classes and data objects aren't exchangeable, yet. So it feels there is some ... something missing, between the class-based idiom seen in static languages, and the object-based (or say map-based) idiom seen in dynamic languages.
JavaFX was pretty neat for building UIs, but Oracle killed it when they bought sun. Now all the features are exposed via plain Java, which gives java a very powerful but verbose scenegraph based UI library. Of course being on the JVM, scala fx provides a dsl that keeps most of the flavor
http://www.scalafx.org/docs/home/
Really this kind of syntax makes building UIs super fast, and is easy to cleanly support in UI building tools. It would be cool if there was a declarative API for polymer dart, and using it would take care of all the import/binding nonsense
From memory I've used variants of the approach described in "The canEqual method" of https://www.artima.com/lejava/articles/equality.html
I think we should be wary in putting too many restrictions on value objects or they will end up as dumbed down as enums and consequently not usable by anyone other than Don Olmstead ;-)
Value objects are often used for domain models and domain models is not an area I believe we should consider giving up inheritance.
Yes that is true, in a pure (non implementation) sense domain models naturally use multiple inheritance, bidirectional relationships etc. When implementing one in code you obviously need to make tradeoffs.
I agree what is really important from the modelling point of view is the relationships which can be captured via interfaces and associations / references.
When implementing the details, mixins can do all you need and are more flexible that implementation inheritance.
That said though I wouldn't agree that we should enforce that you can't inherit implementation from parent classes. In many cases a single parent is all you need so enforcing interface + mixin isn't ideal in that case IMO.
Maybe a restriction that parent classes must be abstract may make some sense, although not 100% for that either ;-)