Daily Thought - 2024-06-22
Hey, I'm Hanno! These are my daily thoughts on Crosscut, the programming language I'm creating. If you have any questions, comments, or feedback, please get in touch!
This thought was published before Crosscut was called Crosscut! If it refers to "Caterpillar", that is the old name, just so you know.
Caterpillar has postfix operators and a stack-based evaluation model, but it isn't a stack-based language. It doesn't use a single data stack to pass arguments and return values between functions. Instead, it works much more like a conventional language, with named arguments and local scopes.
In Caterpillar, every function defines a number of named arguments. The following pseudocode (Caterpillar still does not have a syntax) shows what that could look like:
fn add ( a b ) { a b + }
The arguments are bound to the specified names, a
and b
, which can then be
used as operands. The result of the +
could be used as an operand for another
operation, but in this case, since the function ends there, the unused operand
is returned to the caller.
In a stack-based language, you could write the same function in a more compact way:
fn add { + }
Here, the same global stack is available to all functions, enabling this more compact representation. This has desirable properties, but since I found it too error-prone, it's out for now.
Hey, you! Want to subscribe to my daily thoughts? Just let me know (maybe include a nice message, if you're up for it), and I'll send you an email whenever I post a new one.