Low level details of Fuze Basic
-
Hi,
Would it be possible to know some details about how Fuze Basic works below the surface.
-
It would be great to know how functions with parameters work. I am wondering if parameters are passed by reference or by value. In particular strings and structs. I know I can do some tests to know this but I really think it should be in the documentation. However, I have not been able to find this info yet.
-
It seems that numerical variables are represented as 32 bit floating point values by default. How can you ensure that integer variables stay integer and do not suddenly transition into floating point values when passed to a function or is updated in a mathematical operation. I try to make variables integers by writing 'x = int(0)'. I assume this will make the variable an integer below the surface but I am not sure. And then, what if I pass it to a function, will it then be converted into a float in that function. Example:
x = int(0) // Is 'x' an integer here?
x = f(x) // Is 'x' a float here?function f(d) return d
-
-
it's probably worth mentioning that fuze isn't basic (it's very much a unique language with parts taken from many different languages)
some function parameters are passed by value and others by reference. this needs documenting properly
fuze is very loosely typed, there is a lot of forgiveness when it comes to values stored in strings, arrays, floats, ints and even structures
hope this helps a little!
-
Thanks for your reply. Great that the documentation will be updated concerning function parameters.
However, I am little concerned about the "loose" type handling. Apart from performance issues, floating point variables are not well suited for holding integer values. Strange results can occur, like 'x += 1 x -= 1' not necessarily resulting in 'x' returning to its old value because of the loss of integer precision in the floating point representation. Therefore, it would be nice if you could also document how and when the Fuze language decides to convert types, and also, how to avoid it, if possible. -
@BarenDK said in Low level details of Fuze Basic:
floating point variables are not well suited for holding integer values. Strange results can occur, like 'x += 1 x -= 1'
It's loosely typed meaning things are automatically casted at the point of any operation. we don't store ints as floats for the same reason we don't store strings as ints.
There's no precision lost unless you cast things yourself to change the type too.
Saying that, if you can find an example of it not working as it should, please let me know so I can raise an issue internally for a future patch