zackradisic / aussieplusplus

Programming language from down under
aussieplusplus.vercel.app
609 stars 15 forks source link

Numerical improvements #37

Open bbrk24 opened 2 years ago

bbrk24 commented 2 years ago

Should we consider bitwise operators? I imagine << and >> will run into parsing issues, but |, &, ^, and ~ should be doable. Alternatively, we could use words for all six. (I have no suggestions for what.)

Why does !0 == !1? They both evaluate to YEAH, NAH! which doesn't make sense to me. Typically, 0 corresponds to one boolean and all other integers to the other. This isn't always completely accurate -- for example, Objective-C does this mod 256 -- but I'd say it's pretty uncontroversial that 0 and 1 should have different boolean values.

Should we have literals for NaN and Infinity? It is possible to get them (0 / 0 and 1 / 0 respectively) but I'd prefer them to have names. They currently print as NaN and inf respectively, so if we give them names then the string conversion has to be updated to match.

The syntax highlighting shows literals like 1e9 as if they're numbers, but they don't work: OI MATE! EXPECTED ; BUT GOT 'e9'. It would be nice to be able to express large or small numbers using scientific notation, or have an exponentation operation (like pow() or **) -- preferably both.

bbrk24 commented 2 years ago

~ should be doable.

I forgot that it's already being used for pattern matching. I don't know how much of a problem that would be.

bbrk24 commented 2 years ago
G'DAY MATE!

I RECKON inf = 1 / 0;
GIMME inf == inf;

CHEERS C***!

Gives Yeah, nah!. x != x is the typical test for NaN; generally Infinity == Infinity.