aussieplusplus
aussieplusplus copied to clipboard
Proposal for flexible boolean syntax
Boolean values are currently represented by NAH, YEAH
and YEAH, NAH
, which are perfectly clear and understandable truth statements that all humans should immediately understand, obviously.
Of course we all know that these are the simplest, most idealised ways to express true and false values. A truly aussie boolean representation will need to be more flexible than this.
I would suggest that, in true aussie fashion, the following values should all resolve to true
:
NAH, YEAH
YEAH, NAH, YEAH
NAH, NAH, YEAH, NAH, YEAH
YEAH, YEAH, NAH, NAH, NAH, YEAH
etc. Similar patterns for false
statements, obviously.
I'd suggest that ,
separators between NAH
and YEAH
tokens should also be optional. I.e., the following should all evaluate to true
:
NAH, YEAH
NAH YEAH
NAHYEAH
@jwfxpr Hahaha this is awesome, definitely want to make this happen. There's only one concern I have, and it's that it introduces some ambiguity.
Consider a function that accepts two boolean arguments:
THE HARD YAKKA FOR foo IS (bool1, bool2) <
GIMME "whatever";
>
foo(NAH, YEAH, NAH, YEAH, NAH, YEAH, NAH, YEAH);
How do we know where one boolean ends and the other begins? There are many ways we could interpret the booleans in the function call, for example:
-
NAH, YEAH
andNAH, YEAH, NAH, YEAH, NAH, YEAH
-
NAH, YEAH, NAH, YEAH
andNAH, YEAH, NAH, YEAH
-
NAH, YEAH, NAH, YEAH, NAH, YEAH,
andNAH, YEAH
So I think we'd have to introduce some character to demarcate booleans, the most intuitive one I can think of is just an exclamation point:
foo(NAH, YEAH!, NAH, YEAH, NAH, YEAH, NAH, YEAH!);
What do you guys think?
I think a !
to mark the final value of a boolean chain is good, another way would be to take the commas out entirely 🤔
I'm not sure which is the more entertaining "solution":
foo(NAH, YEAH!, NAH, YEAH, NAH, YEAH, NAH, YEAH!);
foo(NAH YEAH, NAH YEAH NAH YEAH NAH YEAH);
I like the second option because it seems cleaner, but there is something to be said about how ridiculous the first looks with all the commas and exclamation points 😂
What about dropping the commas, but keeping the !
?
foo(NAH YEAH!, NAH YEAH NAH YEAH NAH YEAH!);
I'll leave the question of trailing !
to you, I think it's good both ways!
We may need parser error(s) for handling ambiguous boolean statements. For example, do we consider YEAH YEAH!
to be an invalid expression, or is it sarcastically equal to YEAH NAH!
? What about NAH NAH!
?
If we use exclamation marks, is YEAH YEAH YEAH NAH! NAH
valid, and if so, to what does it resolve?
How do we know where one boolean ends and the other begins?
This issue does already exist, if you declare the variables yeah
and nah
, you can't have them as consecutive arguments to a function.
G'DAY MATE!
THE HARD YAKKA FOR add IS (x, y) <
BAIL x + y;
>
I RECKON yeah = 1;
I RECKON nah = 2;
add(yeah, nah); // <- OI MATE, CAN YA FUCKIN' COUNT?? EXPECTED 2 ARGUMENTS BUT GOT 1
CHEERS C***!
@bbrk24 haha nice catch, hopefully this will be resolved when we move to this new syntax.
As for @jwfxpr's latest comment about ambiguities, we should just say that a boolean is any sequence of NAH
's and YEAH
's separated by whitespace or \n and followed by a terminal !
denoting the end of the boolean. The last YEAH
or NAH
will determine the truthiness of the boolean.
I think the idea of having YEAH YEAH!
being sarcastically equal to YEAH NAH!
is hilarious, maybe we could leave that there as a little easter egg but other than that I don't think it's worth extending the syntax to support sarcasm 😂😂 (can't believe I just wrote that)
NAH YEAH YEAH YEAH NAH! // false
NAH! // false
YEAH! // TRUE
YEAH YEAH YEAH NAH! NAH // error, last NAH does not have a !
Also, having just one YEAH!
or NAH!
doesn't seem like the Aussie spirit, should we force users to have at least two YEAH
s or NAH
s?
(can't believe I just wrote that)
Any discussion of a 'strayan language definition has got to deal with how much sarcasm there is in 'strayan 😂 It's a fundamental part of our language (dry sarcasm, counterfactual naming, etc) and a major reason why speakers of yank in particular struggle so hard with us 😂
But I agree, there's no doubt that a single YEAH
or NAH
is an obviously invalid expression. A valid expression of truth in aussie must be a chain of YEAH
s and NAH
s ending in an unambiguous keyword pair: YEAH NAH!
is clearly false; NAH YEAH!
is clearly true.
Here's an alternative for YEAH YEAH
-- we don't currently have a negation operator, do we? So perhaps YEAH YEAH
can be a negation unary, such that:
I RECKON a = NAH YEAH!; // a is true
I RECKON b = YEAH YEAH a; // b is !a, false
I RECKON c = YEAH YEAH b; // c is !b, true
Since there's no !
present in those expressions, it's not ambiguous between the YEAH YEAH
negation operator and a (e.g.) YEAH YEAH NAH!
boolean expression. If someone wanted to be especially bloody-minded/obfuscated, they can of course explicitly go YEAH YEAH <NAH YEAH!>
or the like...
There's a related opportunity to use NAH NAH
as an or
expression; it returns the left hand side if the left hand side resolves to true, and returns the right hand side if the left hand side resolves to false/null:
I RECKON an_idea = YEAH NAH!;
I RECKON better_idea = an_idea NAH NAH "Got a better idea mate!";
This makes a NAH NAH b
syntactic sugar for YA RECKON a? < a > WHATABOUT ? < b >
and a concise way to BUGGER ALL
-check to a default value. (I'm assuming here that YA RECKON BUGGER ALL ?
is perfectly valid and will skip that branch)
Note that I'm aware that this is getting a bit arcane, but frankly both "yeah" and "nah" are so functional and versatile in 'strayan, it seems right to reflect that in aussie++ syntax 😂. However, won't take a PULL YA HEAD IN @jwfxpr
personally either!
Just added the new syntax, it supports any sequence of YEAH
s and NAH
s ending with an !
and separated by whitespace, ,
or \n
.
Love your other ideas, and if it's such a foundational part of the language then yeah we definitely need to see more of YEAH
and NAH
. Should we close this issue and make another one?
My example from earlier now gives even more errors:
[line 7] OI MATE! expected ! but got =
[line 7] OI MATE! expected ! but got 1
[line 7] OI MATE! expected ! but got ;
[line 8] OI MATE! expected ! but got i reckon
[line 8] OI MATE! expected ! but got =
[line 8] OI MATE! expected ! but got 2
[line 8] OI MATE! expected ! but got ;
[line 10] OI MATE! expected ! but got add
[line 10] OI MATE! expected ! but got (
[line 10] OI MATE! expected ! but got )
[line 10] OI MATE! expected ! but got ;
[line 7] OI MATE! EXPECTED any BUT GOT '='
[line 7] EXPECTED NUMBER, STRING, BOOLEAN, NIL, OR IDENTIFIER BUT GOT '='
[line 8] OI MATE! EXPECTED any BUT GOT '='
[line 8] EXPECTED NUMBER, STRING, BOOLEAN, NIL, OR IDENTIFIER BUT GOT '='
The capitalization, while inconsistent, is what was given. I don't even know what to make of EXPECTED any
.