zackradisic / aussieplusplus

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

Increment/decrement statements #7

Closed jwfxpr closed 2 years ago

jwfxpr commented 2 years ago

GOOD ON YA as increment statement:

I RECKON x = 0;
GOOD ON YA x;
GIMME x;
// Output is 1

PULL YA HEAD IN as decrement statement:

I RECKON x = 1;
PULL YA HEAD IN x;
GIMME x;
// Output is 0

I would expect these to be pre-inc/decrements, where that's relevant

zackradisic commented 2 years ago

Loving the ideas!

1 question, do we want to make it a statement or an expression? If it's an expression we can put put them in other expressions which can open the door to some hilarious possibilities

I RECKON x = 1;
GIMME 420 + GOOD ON YA x;
jwfxpr commented 2 years ago

Yeah, great point, I think they work great as expressions 😂

I RECKON x = 10;
I RECKON y = PULL YA HEAD IN x;
GIMME x - y;
jwfxpr commented 2 years ago

As expressions, perhaps we can then distinguish properly between pre and post inc/decrement:

I RECKON x = 10;
GIMME x PULL YA HEAD IN;
// Prints 10, x now equals 9
zackradisic commented 2 years ago

That looks good to me, unless you wanted to add an additional keyword for pre/post

jwfxpr commented 2 years ago

Well 🤔 I'd say most people are already familiar with the more typical unaries, where ++x and x++ are pre- and post-increment respectively, so having the equivalent expressions be GOOD ON YA x and x GOOD ON YA makes sense to me.

However, since "making sense" isn't this projects highest priority, I'm obviously keen to hear any alternative ideas people have 😄

jwfxpr commented 2 years ago

Wanting to dig into this codebase has motivated me to (finally) start properly learning Rust, and doing so has led me to think that we should not include post-dec/increment in aussie++, for much the same reasons that inc/dec unaries are excluded from Rust (ref for curious readers: Rust FAQ).

Still really wanna see GOOD ON YA x and PULL YA HEAD IN x as unambiguous increment/decrement expressions equivalent to x += 1 and x -= 1 though 😁

zackradisic commented 2 years ago

@jwfxpr really excited about you learning Rust, it's a great language and I could definitely use some help! I should write an ARCHITECTURE.md or something of the sort to help ppl navigate the code 👍

As for the incr/decr expressions, keeping them in the prefix position sounds good to me.

jwfxpr commented 2 years ago

Yeah mate, drifting off topic here but... is there such a thing as a Rustgasm? Rust is what I didn't realise I needed in my life. It's like I didn't realise I had a headache my whole life until it just started going away.

I would definitely encourage at least a CONTRIBUTING.md, and considering the rate at which the repository is accumulating stars and forks, I think you can anticipate more contributions incoming. We can open a contributing issue if you want input on that stuff, but one thing that I think would be nice to see is the All Contributors spec, since you already have really valuable contributions that aren't coming from PRs. 😊

Now, one last back-on-topic note: Implementing this would mean that this language could correctly be referred to as GOOD ON YA AUSSIE, which... I mean... is obviously amazing 😂

zackradisic commented 2 years ago

Yeah I definitely felt the same way about Rust, I started an issue for contributing #21 and just added the All Contributors bot 👍

zackradisic commented 2 years ago

@jwfxpr GOOD ON YA and PULL YA HEAD IN are now added!