notjack
2021-3-8 07:00:18

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))))


jcoo092
2021-3-8 07:05:25

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:


notjack
2021-3-8 07:06:45

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%.


notjack
2021-3-8 07:08:45

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)); }


notjack
2021-3-8 07:09:18

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))


notjack
2021-3-8 07:09:20

etc.


jcoo092
2021-3-8 07:10:26

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?


notjack
2021-3-8 07:10:39

give it 5–10 years


notjack
2021-3-8 07:11:46

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


sorawee
2021-3-8 07:11:51

TypeScript can do that, perhaps partially


jcoo092
2021-3-8 07:13:42

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.


notjack
2021-3-8 07:15:07

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.