tatumizer-v0.2
2015-08-28 03:11:53 UTC
Here's a raw idea - we discussed something similar before, but I think
prior proposals missed one simple variant.
.
The following fragment is taken from Lasse's original proposal. Exact
syntax doesn't matter though.
import dart.platform == "browser" : "some uri.dart"
|| dart.platform == "standalone" : "other uri.dart"
|| "default uri.dart"
deferred as foo show x hide y;
I think the mistake here is an attempt to create a union of different
libraries, which most likely have incompatible interfaces.
Instead, we better keep them separate by writing separate import statements
and assigning different name to each library variant:
import "some uri.dart" *as foo* when dart.platform=="standalone";
import "other_uri.dart" *as bar* when dart.platform=="browser"
When we work in IDE, analyzer will (internally) load *all* library variants.
In the code, access to the stuff coming from conditionally imported library
should be guarded by
if (imported(foo)) { // "imported" is an intrinsic function
// use foo.anything
}
...
if (imported(bar)) {
// use bar.anything
}
Unguarded access is an error.
Naturally, when compiler really generates the code, it ignores all
libraries that don't meet import conditions, and removes corresponding
(dead) parts of code.
However, in IDE, every feature continues to work, because all variants are
loaded (internally), .
Any counterexamples?
BTW, the idea is quite simple, maybe it was considered and rejected - I'd
like to know why.
prior proposals missed one simple variant.
.
The following fragment is taken from Lasse's original proposal. Exact
syntax doesn't matter though.
import dart.platform == "browser" : "some uri.dart"
|| dart.platform == "standalone" : "other uri.dart"
|| "default uri.dart"
deferred as foo show x hide y;
I think the mistake here is an attempt to create a union of different
libraries, which most likely have incompatible interfaces.
Instead, we better keep them separate by writing separate import statements
and assigning different name to each library variant:
import "some uri.dart" *as foo* when dart.platform=="standalone";
import "other_uri.dart" *as bar* when dart.platform=="browser"
When we work in IDE, analyzer will (internally) load *all* library variants.
In the code, access to the stuff coming from conditionally imported library
should be guarded by
if (imported(foo)) { // "imported" is an intrinsic function
// use foo.anything
}
...
if (imported(bar)) {
// use bar.anything
}
Unguarded access is an error.
Naturally, when compiler really generates the code, it ignores all
libraries that don't meet import conditions, and removes corresponding
(dead) parts of code.
However, in IDE, every feature continues to work, because all variants are
loaded (internally), .
Any counterexamples?
BTW, the idea is quite simple, maybe it was considered and rejected - I'd
like to know why.
--
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+***@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+***@dartlang.org.