[Grace-core] Import statements

James Noble kjx at ecs.vuw.ac.nz
Sun Jun 9 15:21:48 PDT 2013


Hi all

catching up...

> Here is a language design (rather than minigrace) issue.
> 
> Currently import statements must take a string as an argument.  E.g.
>   import "objectdraw" as od
> 
> However, this makes programs fragile, as all the import statement need to be rewritten if the program is moved to a new directory or computer.  I would suggest that we make this a bit more flexible via one of the two following suggestions:

So I do think there is more to consider here - but I'm not sure we're ready to move forwards on this yet.

Remember that the language spec should be as independent (as possible) from the implementation - 
a lot of this discussion seems to assume the current c-like minigrace model - not even the JS version.
All the spec says for now is that that the distribution model should be source code - not e.g. some compiled representation. There clearly is a need to think about how that model works when we have
more than one module / file, and I dont think we've done that.

for C, the obvious thing to do is just to have some kind of path environment variable.
yes, I can hear all the wailings of java developers complaining about CLASSPATH - and they're right.

Lex Spoon writes:

> Conceptually, I would emphasize the concepts of "dependency" and "dependency resolution".

and i think this is a good place to start. We do need to handle "dependency injection"
one way or another - the simplest case is which version of simplegraphics to use
(depending on GTK or JS backend).  But there will (hopefully?) be many others.

>  it is important to assume that there is
> extra information outside the language to resolve dependencies.

right. certainly outside the modules being linked - 
one possibility I've considered is effectively a grace dialect to do that...

I'd like to quibble more about Lex's points in detail, but I do think he's heading in the right direction.

> DNS names. I know it's an unpopular opinion, but I think the Java convention is slightly wrong


there are a range of ways to handle this. 
racket has a central repository and makes it easy to download packages from there.

GO has a slightly different approach

http://www.stovepipestudios.com/blog/2013/02/go-dependency-management.html


I notice one of KIm's wish list items is:

> A last question, if I want to run programs from somewhere outside of the grace-gtk subdirectory, what do I need to do?  I've tried putting in both relative and absolute path names to get to the objectdraw library from outside that directory, but have had no luck.  Is there something simple I am missing?  It's awkward to have all the programs and library in the same directory.

so we need to think about this, but try for a general & simple solution - if that's possible

James


More information about the Grace-core mailing list