Post by tatumizer-v0.2If you consider Android vs iOS, each coming with a large set of libraries,
// foo.dart
export 'foo_interface.dart'
if (dart.library.ios) 'foo_ios.dart'
if (dart.library.android) 'foo_android.dart';
So, a lot of tiny dart files, none of which actually looking like a
program. Rather, they are pieces of configuration. And they are not DRY by
any measure: "bar.dart" will be a copy of "foo.dart" with substitution
s/foo/bar/g, etc - and same for each library.
And in which package will you put all those?
In a recent thread, Eric argued against the idea of static id for a
closure on a basis that the
(that might be me, in which case it's with a 'k' ;)
Post by tatumizer-v0.2feature belongs to reflection (not to runtime per se). But if we apply
same logic here, this "configured imports" idea looks like a roundabout and
complicated way to implant pieces of *configuration* into the program, so
similar argument can be made: the thing doesn't belong in a program, it
should be part of some config file, or metadata, or something.
If you have a lot of tiny libraries just containing a configurable 'export'
then you are implicitly turning all the importers (of one or more of those
tiny libraries) into configuration dependent code: If they really get to
import different bodies of code depending on the configuration then the
meaning of every tiny snippet of code in those importers might be different
in different configurations. For instance, the occurrence of `x` in the
body of a method could resolve to a tear-off of an inherited method in one
configuration, and it might denote a top-level const variable of type `int`
in another configuration. It might even work, somehow. ;-) In this case
you'd need to have the complete list of possible interpretations of every
snippet of code in mind whenever you are trying to read the code in those
importers, and of course even more when you are modifying existing code or
writing new code.
I've stubbornly argued that this complicates the software, and it would be
better to encapsulate the configuration dependencies and have the rest of
the software use configuration dependent features via a well-defined,
explicit, configuration independent interface, and checking statically that
it is used and implemented correctly, with the strictness-vs-soundness
trade-off that we know from the rest of the language.
The obvious alternative is that we could compare the imported interfaces
and make sure they are "sufficiently similar". But I never liked
introducing structural type equivalence into Dart, because it is a whole
new not-quite-identical copy of the type system---hardly a way to make
things simple. That's the reason why I've proposed not importing types
configurably; all types visible to "configuration independent code" should
be strictly configuration independent (otherwise that code ain't
configuration independent at all), and configuration dependent code should
then conform to those types (it's perfectly OK for a configuration
dependent library to import configuration independent ones, so it can
easily get to see the relevant types).
So I'm much less happy about a configuration dependent _export_ than I am
about a configuration dependent _import_ which is used to provide a
configuration independent set of features to the configuration independent
domain. It's more verbose to provide a configuration independent interface
and to tie an existing implementation up to it, but I believe that those
fewer keystrokes could end up being an expensive short-cut in perspective.
Looking at it from different perspective: if library is intended for use
Post by tatumizer-v0.2only on android platform, wouldn't it be logical for this program to
declare this fact explicitly (e.g. via some pragma, or "library foo for
*platform*" etc)? Or maybe the whole package deals with android - it can
say "for android only" in pubspec? There are several ways to proceed from
here. (I'm sure this option was considered. What exactly was found wrong
with it?)
That is quite interesting! ..but configurable imports might as well be used
for non-platform variants, e.g., software product lines. I don't think that
it would be possible to make all the configuration related choices based on
information on the form "this library inherently cannot be used here".
best regards,
--
Erik Ernst - Google Danmark ApS
Skt Petri Passage 5, 2 sal, 1165 KÞbenhavn K, Denmark
CVR no. 28866984
--
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.