www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - API Evolution

reply bearophile <bearophileHUGS lycos.com> writes:
This is a bit related to the discussion about version().

In the Lambda the Ultimate blog-forum they are discussing about better support
in languages for API Evolution:

http://lambda-the-ultimate.org/node/2950

In the discussion someone has said that it may be useful a syntax to specify
what version of a module/package must be imported. (And now and then I have
seen people in Python mailing lists ask for something similar, they have
several versions of the same module/package and they want other modules to
import only the right version).

A first possible raw idea:

This looks for a module foo strictly version 1.3:
import foo(1.3, 1.4) : bar;

This looks for a module foo version 1.3 or 1.4 only:
import foo(1.3, 1.4) : bar;

This looks for a module foo version 1.3 or successive:
import foo(1.3, +) : bar;

The compiler is of course supposed to look for modules by itself, as bud does,
and it rises a compilation error if an acceptable version isn't available.

That idea may also need a way to define the version of the current module, a
raw idea:

module foo(1.4);

A small problem is that versions of such module/package will have the same
name, so you can't put them in the same directory...

Bye,
bearophile
Feb 11 2009
parent reply Daniel Keep <daniel.keep.lists gmail.com> writes:
bearophile wrote:
 This is a bit related to the discussion about version().
 
 In the Lambda the Ultimate blog-forum they are discussing about better support
in languages for API Evolution:
 
 http://lambda-the-ultimate.org/node/2950
 
 In the discussion someone has said that it may be useful a syntax to specify
what version of a module/package must be imported. (And now and then I have
seen people in Python mailing lists ask for something similar, they have
several versions of the same module/package and they want other modules to
import only the right version).
 
 [snip]
 
 Bye,
 bearophile
Couldn't you just compile with a specific version? I don't see a reason for the language to support this when D currently doesn't even have the concept of libraries. If anything, this should be a candidate feature for DSSS. Maybe you could do it like so: version( build ) { // Obviously, you'd only use ONE of these... pragma( library_version, derelict.gl, "1.3.*" ); pragma( library_version, derelict.gl, "1.3.*", "1.4.*" ); pragma( library_version, derelict.gl, "1.3+" ); } import derelict.gl; DSSS could then download and install the appropriate version if it isn't already present. -- Daniel
Feb 11 2009
parent Chad J <gamerchad __spam.is.bad__gmail.com> writes:
Daniel Keep wrote:
 bearophile wrote:
 This is a bit related to the discussion about version().

 In the Lambda the Ultimate blog-forum they are discussing about better support
in languages for API Evolution:

 http://lambda-the-ultimate.org/node/2950

 In the discussion someone has said that it may be useful a syntax to specify
what version of a module/package must be imported. (And now and then I have
seen people in Python mailing lists ask for something similar, they have
several versions of the same module/package and they want other modules to
import only the right version).

 [snip]

 Bye,
 bearophile
Couldn't you just compile with a specific version? I don't see a reason for the language to support this when D currently doesn't even have the concept of libraries. If anything, this should be a candidate feature for DSSS. Maybe you could do it like so: version( build ) { // Obviously, you'd only use ONE of these... pragma( library_version, derelict.gl, "1.3.*" ); pragma( library_version, derelict.gl, "1.3.*", "1.4.*" ); pragma( library_version, derelict.gl, "1.3+" ); } import derelict.gl; DSSS could then download and install the appropriate version if it isn't already present. -- Daniel
This kind of thing would be awesome, whether it be by language builtins or by DSSS. It's also the kind of thing I might just get frustrated and write at some point. DSSS needs to act a bit more like portage ;)
Feb 11 2009