
wistfully imagining an alternate universe where racket binding forms are built around three constructs: • (block body …)
- an expression that allows internal bindings • (let pattern expr)
- like match-define
but with shadowing like let
• (function header body …)
like define
but only allows defining functions, and function arguments can be match patterns (struct point (x y))
(function (distance (point x1 y1) (point x2 y2))
(let dx (- x2 x1))
(let dy (- y2 y1))
(sqrt (+ (sqr dx) (sqr dy))))

To my mind, if you take away the parens and reverted from prefix to infix operators, that looks pretty much exactly like Standard ML & friends. I’m a fan overall of the ML family, so I think that’s a good thing :slightly_smiling_face:

toss in braces and it’s pretty much 80% of mainstream languages. toss in colons and significant indentation and it’s probably the other 20%.

struct point(x, y)
function distance(point(x1, y1), point(x2, y2)) {
let dx = x2 - x1;
let dy = y2 - y1;
sqrt(sqr(dx) + sqr(dy));
}

struct point(x, y)
function distance(point(x1, y1), point(x2, y2)):
let dx = x2 - x1
let dy = y2 - y1
sqrt(sqr(dx) + sqr(dy))

etc.

Mostly true, but I don’t think all that many mainstream languages do pattern matching in function parameters yet, do they? Or am I forgetting things?

give it 5–10 years

java and python both have some pattern matching with more proposals for it in the works

TypeScript can do that, perhaps partially

As an aside, I loathe whitespace/indentation having semantic (or would that be syntactic?) significance. I’m not the world’s number one fan of s-expressions, but I’ll take them any day over a missing space screwing things up mysteriously.

I generally agree. I also think a lot of the redundancy issues of the braces-and-semicolons style go away if your editor automatically formats your code for you.