doonv / bevy_dev_console

Source-inspired developer console plugin for the Bevy game engine.
Apache License 2.0
121 stars 11 forks source link

Additional number types (and type inference) #2

Closed doonv closed 10 months ago

doonv commented 10 months ago

Currently, the built-in parser only supports f64 numbers.

We can easily separate numbers into f64 and i64s by if they have decimals or not.

But what about other sizes? This is where it gets a tad complicated because we want type inference. Technically we don't need type inference but needing to specify the type of a number every time gets annoying pretty quickly.

Solutions

Rust uses whats known as a Hindley–Milner type system, but the Wikipedia article about it seems quite complicated. So I think that's a no-go (unless someone else decides to contribute it in, help would be appreciated)

An easier approach would be to look at what the function/variable assignment is expecting and use that, if that doesn't help then default to i32 / f32.