--
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.
If Dart is not gonna give us method overloading, to prevent api bloat like this, then we need pattern matching/guards. Otherwise the choice is API bloat, or parameters are marked dynamic with impl using if-else matching.Excuse my dart/scala lovechildPoint3D project(dynamic axisOrPlane) {pointOrPlane match {case axis:Axis => doAxisStuff(axis)case plane:Plane => doPlaneStuff(plane)}}
In Scala you can with sealed case classes catch the case at compile time where matches are not exhaustive. Otherwise usually good practice to have a final guard to trap on a common super class or unknown case.
case _ => … unexpected edge case. Underscore is 'matches everything'
--
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.
But it seems to me, wouldn't it make more sense for axis or plane to know how to project points, and not point3D?// Simply holds a point in space, should know nothing about projectionclass Point3d{}class Plane3D{Point3d projectPoint(Point3D)}class Axis3D{Point3d projectPoint(Point3D)}
--
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.
In C++ or Java when you have access only to a base class representation of an object, yet you still want to dispatch polymorphically, you implement double dispatch. Perhaps that a solution in this case.