essential-contributions / pint

Pint, the constraint-based programming language for declarative blockchains
Apache License 2.0
17 stars 3 forks source link

Disallow `state`, `var` and `pub var` decls in macro expansion? #775

Open mitchmindtree opened 2 months ago

mitchmindtree commented 2 months ago

This is a follow-up to the discussion in #772 starting here.

I guess if we decide to not allow declaring vars and pub vars in macros then I could not merge this PR and just change the integration apps to not do that?

@freesig I'm still open to the idea that they might be useful, but I think in the use-case you gave I'd probably write it a little differently, e.g.

freesig commented 2 months ago

Yeh I can clean that up a bit. One area this does come up is with authentication. We currently are doing:

    var auth_addr: PredicateAddress;
    @auth(auth_addr; key; auth::@burn());

Technically we could put the var inside the macro as it's only use in there. This avoids the user of the @auth library macro needing to know that they have to pass in this var which they never even use. This is especially a problem because there's no type signature on macros.

I do see the other side of this though, you can really look at it both ways (all inputs as args to a giant function vs vars used within scopes).

I think we should also include vars declared in other files in this convo (if that's actually possible atm).