Importing

The import keyword is followed with a relative or absolute library identifier. This library will be loaded in it's own scope ( a branch of the current scope) and it's entry point executed as a function. The result of which will be returned from the call to import.

var file = import "lib/file"
file.read("foo.txt", txt -> print(txt))
import uses a convention based scheme where it will resolve either IL libraries or verse script files and execute them based on the import string specified.

It is possible to specify a pattern to use when importing. The input from the imported file is passed into the pattern instead of parsed directly as a verse script.

var p = pattern any+
var dsl = import "test.dsl" with p
The final production of the pattern is what ends up being imported.

Last edited Nov 24, 2012 at 4:47 PM by justinc, version 1

Comments

No comments yet.