Advanced features

Import statement

Hurdy includes a Python-like import statement, which can be used to quickly declare and assign local variables from the entries of a table:

from expr import x, y, test

is equivalent to

var _hurdytemp1 = expr -- number of the temporary variable is incremented each time
var x = _hurdytemp1.x
var y = _hurdytemp1.y
var test = _hurdytemp1.test

expr need not be a variable name, but can be more generally an expression (function call, table indexing, etc.). The following are all valid uses of the statement:

from x import x, y
from require("library") import x, y
from t.subtable import x, y
from a + b import x, y -- allowed, but needs methametods for it to make sense
from nil import x, y -- technically allowed, but doesn't make sense

The variable names can optionally be changed with the extended version of the command

from expr import x, y, test as z, w, test

-- names must be provided for all entries

which is equivalent to

var _hurdytemp1 = expr
var z = _hurdytemp1.x
var w = _hurdytemp1.y
var test = _hurdytemp1.test