making good progress on my parser, and now i'm thinking of committing some crimes >:3
that being having both `and` and `&&`, and `or` and `||`, where the latter coerces to bool and the former does not and acts like lua >_>
making good progress on my parser, and now i'm thinking of committing some crimes >:3
that being having both `and` and `&&`, and `or` and `||`, where the latter coerces to bool and the former does not and acts like lua >_>
in less trolling news i'm really liking the way if/while/etc blocks work in this syntax. either you do this
if x { ... }
or you do
if x: print "single line";
so the colon delineates the end of the condition but is optional if you have a {} block instead of a single line. and yes, this is also valid:
if x: { ... }
Trying to think of what's left for my parser before I can start writing and compiling actual programs. Right now all it knows is integers. I guess if I expose some stuff to interact with memory handles and the VM's system calls I could make real programs?
It'd be nicer to have like, actual pointers and strings and arrays though, but that's a lot more work. So maybe I should just do the quick and dirty way for now?
@eniko fair enough! Remember that you can choose a syntax that's amenable to iterators later.
For example, Rust's `for x in 0..N` syntax works with any iterator instead of a range, but there's no reason why you couldn't hard-code the range pattern for now and solve the general behaviour later :)
@eniko A slightly different form is Reverse Polish Lisp: 1 10 for x next :)
(Whenever I've written my own languages I make them Forth or RPL style, since it's so much easier to write the interpreter)
@eniko yall got lambdas?
```for_each (sequence, ^ (item) {
work (item);
});
for_each_n (sequence, ^ (item, i) {
work (item);
array[i];
});```
etc
then later you could do what Ruby/early Rust did and allow the recursion-operators to curry and implicitly use trailing-call syntax:
for_each (sequence) ^(item) {
work (item);
};
(i am hung up on this :P)
parents, talk to your children about programming languages before it's too late 😂
@eniko
If you're already treating a {..} block also as an expression, as per your "if" post, you could go the route TCL went, ie
for start test next body
E.g.
for {set i 0} {$i < 10} {incr i} {
puts "I inside first loop: $i"
}
From https://www.tcl-lang.org/man/tcl8.5/tutorial/Tcl10.html
@eniko yea that's reasonable. If a : then only one statement, if { then a whole block
i like this
@aeva "why the fuck does this ubiquitous language have two logical and operators??"
Because I thought it would be funny
Fortunately it's almost guaranteed I'm not gonna roll a 100 on a d100
@eniko still better than doing &, && and &&& so go ahead, it's atleast your language
~ a C# dev that might just be used to not caring anymore
@eniko you've gone mad with power!
But also, Coldfusion - my first language - used keywords. It was jarring going between it and JavaScript.
@eniko Elixir sorta does this!
and and or strictly work with boolean arguments (i.e. it is a type error to call them with non-booleans), whereas && and || work with truthy and falsey values.