noname icon indicating copy to clipboard operation
noname copied to clipboard

Map native functions to builtin operators

Open katat opened this issue 1 year ago • 2 comments

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.

katat avatar Oct 24 '24 06:10 katat

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

mimoo avatar Oct 25 '24 19:10 mimoo

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

katat avatar Oct 28 '24 07:10 katat