essential-contributions / pint

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

Abi gen pub vars #773

Closed freesig closed 2 weeks ago

freesig commented 3 months ago

Currently the abi gen handles pub vars like state mutations but I think the current implementation of pub vars expects that all pub vars are set. Does this work?

pub var a: int;

constraint a == nil || a == 1;

I think we really need to pick a direction with pub vars. They are either like storage and can eventually support things like map and it's possible for them to be nil like storage (and we can check for nil). Or they are the same as vars and must all be set.

I think the first option is much more powerful and fits the original intention for pub vars but currently it's very confusing being in this middle ground.

Users won't realize that they have to set all the pub vars because it's not a struct like vars are.

mitchmindtree commented 3 months ago

Related https://github.com/essential-contributions/pint/issues/735.

mohammadfawaz commented 3 months ago

the current implementation of pub vars expects that all pub vars are set.

Hmm I don't think there's a restriction anywhere. If a pub var is not constraind, for example, a solution is allowed to set it to nil. The only missing piece is being able to compare them to nil so that's something we can add. But certainly we shouldn't require them to be set.