Skip to content

Need macro 'splice' builtin #2

@ehren

Description

@ehren

example:

defmacro(do_loop (:
    stmts
while: condition), stmts: [Node], condition:
    first_time = gensym()

    # TODO - with splice:
    # return quote(scope(:
    #    unquote(first_time) = True
    #    while (unquote(first_time) or unquote(condition):
    #        unquote(first_time) = False
    #        splice(stmts)
    #    )
    # ))

    # without splice:

    while_stmts: mut:[Node] = [quote(unquote(first_time) = False)]
    unsafe(while_stmts.insert(while_stmts.end(), stmts.begin(), stmts.end()))
    while_block = Block(while_stmts)

    return quote(scope(:
        unquote(first_time) = True
        while (unquote(first_time) or unquote(condition), unquote(while_block))
    ))
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions