if version\0 < 1:
raise = PRIMOP{'Fraise'}
print = PRIMOP{'Fprint'}
pprint = PRIMOP{'Fpprint'}
pformat = PRIMOP{'Fformat'}
quote = PRIMOP{'Fquote'}
iter = PRIMOP{'Fiter'}
kiter = PRIMOP{'Fkiter'}
spawn = PRIMOP{'Fspawn'}
import_fast = PRIMOP{'Fimport'}
import = PrimaImport
ask_root = PrimaConsoleQuestion
sleep = PrimaSleep
resume = PrimaResume
str = PRIMOP{'Fstr'}
format_time = PRIMOP{'Fformat_time'}
append = PRIMOP{'Fappend'}
truncate = PRIMOP{'Ftrunc'}
length = <l: l.__length__>
span = <a, b: Range(start=a, stop=b)>
sjoin = PRIMOP{'Fsjoin2'}
joinlines = sjoin{sep='\n'}
reversed = PRIMOP{'Freversed'}
read_file = PRIMOP{'Fread_file'}
file_lines = PRIMOP{'Ffile_lines'}
{|
| Wait until func() returns a known value.
|
| The DSL compiler uses this for "x!"
|
| I.e., "foo.x!" desugars to
| wait_until_known(<foo.x>)
|}
def wait_until_known(func):
for val in func:
if val?:
return val
{|
| Return the first len items of list l.
| Returns l if length(l) <= len
|}
def trunc(l, len):
if length(l) <= len:
return l
ll = []
for i:v in l:
if i >= len:
return ll
append(ll, v)
return ll
def list(itr):
l = []
for v in itr:
append(l, v)
return l
def set(itr):
s = {}
for v in itr:
append(s, v)
return s
def tuple(itr):
return PRIMOP('Ftuple', list(itr))
{|
| This adds a new property to an existing type.
|
| This behaves the same as if the equivalent field
| line was added to the original definition of type.
|
| Returns the resulting Property Object.
|
| (This isn't really needed any more since you can
| amend types with a normal type declaration, but
| useful I guess for eventual meta programming.)
|}
def add_property(type, mode, name, default):
return PRIMOP('Ftype_field2', type, name, mode, default)
version = 1