[Grace-core] Import statements

Kim Bruce kim at cs.pomona.edu
Mon Jun 3 23:39:30 PDT 2013


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:

1.  Allow a prefix to be added to a string:

def base ="home/kim/graceprogs/"
import base++"objectdraw" as od

2.  Allow an import to provide an address

in file "platform" put

def objectdraw = "home/kim/graceprogs/objectdraw"
def gtk = "home/kim/MiniGrace/grace-gtk/gtk"
...

then use them as:

import "platform" as platform
import platform.objectdraw as od
import platform.gtk as gtk

--------
Of course, even better would be to combine the two by allowing the base to be defined in "platform".

Is there any reason not to do these?  They make life much easier when using standard libraries, especially when students will be copying them to their own directories and having to fix up library references!

Kim





More information about the Grace-core mailing list