Mustafif / MufiZ

Mufi Lang with Ziggyness
GNU General Public License v2.0
1 stars 0 forks source link

Softening Numeric Type Requirements in Builtins #24

Closed Mustafif closed 2 months ago

Mustafif commented 2 months ago

Consider the following example:

var v1 = linspace(1.0, 2.0, 2);
var v2 = linspace(1, 2, 2);

Currently, v1 can compile, but v2 can't since the first and second arguments need to be strictly double. However, we should enable the user to choose either version and for them to be the "same."

The notion of softening the numeric type means that if we expect a double but receive an int, then we accept any number type (double, int) and cast it to the correct expected type. This means we need a new macro IS_NUMBER to check if its either a double or integer, and another macro or function to cast it to the correct expected type. This change should resolve many accidental compile errors for the users, and simplify builtin requirements as we can just simply say any number (real).

Mustafif commented 2 months ago

Currently C side is complete, the Zig side will be next to tackle

Mustafif commented 2 months ago

Initial work completed in https://github.com/Mustafif/MufiZ/commit/f78b6c9da58405923a8793e1d65497c31dabec8a C side completed in https://github.com/Mustafif/MufiZ/commit/f5e8e3ed68e1e3fbce0fc8da3b7d1a3e0c45ccd5 Zig side completed in https://github.com/Mustafif/MufiZ/commit/2f64aab5d730991dab42ed43bba09ff6af1a1c6e