(|
 | For now init.largo is compiled and run every launch (no attention
 |  to module level version) just to make development easier, but
 |  eventually we'll version this too to avoid needless recompiles.
 |  Regardless the logic should be idempotent:
 |)
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'}     -- This one doesn't wait for the module to load
    import      = PrimaImport           -- This one does
    ask_root    = PrimaConsoleQuestion
    sleep       = PrimaSleep
    resume      = PrimaResume
    str         = PRIMOP{'Fstr'}
    format_time = PRIMOP{'Fformat_time'}
    append      = PRIMOP{'Fappend'}
    truncate    = PRIMOP{'Ftrunc'}      -- Truncate (or extend) a list in place
    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:
                -- break for
                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))  -- Very inefficient, but general?

    {|
     | 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):                    -- field syntax order
        return PRIMOP('Ftype_field2', type, name, mode, default)    -- internal logic order

    version = 1