zksecurity / noname

Noname: a programming language to write zkapps
https://zksecurity.github.io/noname/
181 stars 47 forks source link

can we get rid of the `const` keyword? #22

Open mimoo opened 6 months ago

mimoo commented 6 months ago

check the iterate.no example:

fn House.room(self, const idx: Field) -> Room {
    return self.rooms[idx];
}

do we really need the const here? Can't we just have the compiler complain if you pass a variable instead of a const for an actual circuit? It feels to me like this keyword just adds more mental load to the developer

(I did document the decision back then)

mimoo commented 6 months ago

in my notes I had "replace const Field with Number or Int or smthg"

mimoo commented 4 months ago

I think the const keyword is acting like a generic right now, which is nicer than having an extra syntax like fn House.room[idx](self) IMO