Skip to content

Conversation

@jurgenvinju
Copy link
Member

@jurgenvinju jurgenvinju commented Nov 21, 2025

This is not a priority. Added some enhancements to ICollector be able to write:

void collect(current: (Program) `begin <Declarations decls> <{Statement  ";"}* body> end`, Collector c){
    c.scope(current, () {
        collect(decls, body, c);
    });
}

instead of:

void collect(current: (Program) `begin <Declarations decls> <{Statement  ";"}* body> end`, Collector c){
    c.enterScope(current);
        collect(decls, body, c);
    c.leaveScope(current);
}

The scope shorthand (and its siblings lubScope, compositeScope, compositeLubScope, ...) also wraps a try-finally block around the block, such that in the presence of unexpected exceptions the scope stacks are properly unwound automatically.

The changes are located purely in the abstract definition of ICollector as a list of keyword parameters that call the other function fields. So the scope keyword parameter calls the enterScope and leaveScope positional field, etc. There is no impact on other code in typepal.

…and safe scope and stack pushes and pops. shorthands for manual enter/leave, push/pop pairs
…atted a switch and changed list to tuple syntax for better efficiency
@jurgenvinju jurgenvinju marked this pull request as ready for review November 21, 2025 08:11
@jurgenvinju jurgenvinju self-assigned this Nov 21, 2025
@DavyLandman DavyLandman force-pushed the blocked-stack-shorthands branch from d95f86d to cb99eee Compare November 24, 2025 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant