fuzion icon indicating copy to clipboard operation
fuzion copied to clipboard

type inference num literals

Open michaellilltokiwa opened this issue 1 year ago • 3 comments

Currently the type of numeric literals can be inferred based on its assignment to be one of the supported primitives, e.g. u8, ..., i64 etc. Maybe it makes sense to generalize this to features that take exactly one argument that is of a supported type.

An example:

ex =>

  wait(a ms) is

  ms(val u64) is

  three_ms ms := ms 3
  wait (ms 3)

  three_ms ms := 3    # does currently not work
  wait 3              # does currently not work

michaellilltokiwa avatar May 13 '24 11:05 michaellilltokiwa

I have a hard time wrapping my head around this idea, I don't see why this should work.

maxteufel avatar May 15 '24 11:05 maxteufel

@maxteufel It should work similar as type inference for e.g. i32(val i32) is

We may have to wrap the numliteral and generate a call to the feature e.g. for wait ms / wait 3 will be turned into wait (ms 3)

michaellilltokiwa avatar May 15 '24 12:05 michaellilltokiwa

My comment was perhaps not written well, what I meant is that I don't see the point for this. It sure is syntax sugar for less typing, but I don't see how it makes sense from a programming language standpoint.

maxteufel avatar May 15 '24 12:05 maxteufel