envy for "Writing Go Packages"

Nick Sabalausky a at a.a
Sun May 9 11:34:34 PDT 2010


"BCS" <none at anon.com> wrote in message 
news:a6268ff137a98ccbd7270f72004 at news.digitalmars.com...
> Hello Robert,
>
>> no language
>> changes needed (except maybe to remove the .ver1_23... how would the
>> compiler know when to do this though?).
>
> how about a pragama:
>
> pragma(ver, "1.23", "$") import foo.bar.baz; // imports foo.bar.baz, 
> require a version at or later than 1.23

I have a mixed opinion on that. On one hand, being able to specify either a 
specific version or an arbitrary range matches real-world cases much better 
than "any version" vs "this exact version". However, different programs and 
libs use different versioning conventions. For example: Are "v1.1" and 
"v1.100" the same or is the latter much newer? Or, which is first, "v1.100" 
vs "v1.99"? Also, I can imagne certain programs may be able to work with 
more complex ranges. For instace, maybe FooApp can use BarLib's "v1.x" 
branch as long as it's at least "v1.7", and it can also use any version of 
the "v2.x" branch from "v2.1" through "v2.5", but "v2.4.3" through "v2.4.8" 
are known to have problems.

So maybe trying to allow ranges (even one as simple as "at least vX.X") is 
just too complicated, and should be left to static if(), and the "helping 
the compiler automatically download/install a dependency" should be limited 
to an option between one specific known-working version or the latest 
version. So something roughly like:

enum suggestedBarLib = "http://www.barlib.com/packages/barlib-v2.6.dstone";
pragma(ifMissingGetFrom, suggestedBarLib) import barlib;
static if(!IsAcceptableBarLibVersion!(BarLibVersion))
{
    pragma(importFrom, suggestedBarLib);
}

And then maybe some sort of sugar could be added later (maybe it could all 
be wrapped up in a mixin).




More information about the Digitalmars-d mailing list