zksecurity / noname

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

Map native functions to builtin operators #214

Open katat opened 1 month ago

katat commented 1 month ago

It would be nice to support builtin operators like + - / % << >> etc for both field and uint types.

Instead of implementing them as via builtin interfaces, like this pending PR, it would be better to implement them in native noname code, which are easier for maintenance.

To achieve this, we would map these operators to the native functions, such as uints.

The mapping could be in the MAST phase, where the builtin operator AST nodes can be replaced with function calls to the native stdlib.

mimoo commented 1 month ago

So as long as a type implements a known signature (e.g. Type.add(Type) -> Type) we would automatically route a + to that function right? Sounds like a good idea

katat commented 1 month ago

Yes, we will need this assumption until noname support trait.