Daily Thought - 2025-02-14
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!
Postfix syntax has advantages over prefix syntax, but you can offset those. And there is at least one genuine advantage that prefix syntax has over postfix (besides familiarity; which, to me, doesn't count). Because this is shit:
condition
then_case
else_case
if
This is a fictional postfix syntax for an if
expression. And I don't like it,
because I have to read three distinct pieces of code (condition, "then" case,
"else" case) before I'm told the context (if
) that could help me understand
this.
We can make that a bit better by being more explicit:
{
condition: ...
then: ...
else: ...
}
if
At least this way, you see a record type that starts with a condition
field,
and can pretty much assume what this is going to be. But it's not the same as
knowing the context of what's happening from the start. Like you would, if this
was using prefix syntax, and if
was the first thing you saw.
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 every time I post a new one.