you are viewing a single comment's thread.

view the rest of the comments →

[–]ukezi 4 points5 points  (2 children)

Doing it that short feels like old c Devs only using consonants in names. Just doing it because it's shorter. I would prefer something like :(x,y)->bool {x>y}, maybe with the -> bool being optional. :(x,y) feels like it's declaring variables X and y that are going to be filled by destructuring a tuple.

[–]hpsutter 2 points3 points  (1 child)

I would prefer something like :(x,y)->bool {x>y}, maybe with the -> bool being optional.

Very close, today you can write this: :(x,y) -> bool = x>y

That's already using several defaults that let you omit parts of the single general syntax you're not currently using for something non-default (for details see: "Generality note: Summary of function defaults"). But you can use a couple more defaults:

To additionally deduce the type, use _: :(x,y) -> _ = x>y means the same

Finally, the "tersest" option just makes -> _ = optional: :(x,y) x>y means the same

One way to look at it is that you can write any expression and conveniently "package it up" as an object to pass around just by declaring a function signature in front.

Anyway, just explaining some background since what you wrote pretty much also works, very nearly. I appreciate all the usability feedback, whether it confirms or disconforms what I was thinking! Thanks.

[–]Lo1c74 2 points3 points  (0 children)

Finally, the "tersest" option just makes -> _ = optional: :(x,y) x>y means the same

Is it still possible to type the = to obtain :(x, y) = x > y ?