Hacker News new | ask | show | jobs
by tomp 2923 days ago
Thanks for this!

This is by far the most what the fuck language that I've seen in a long while. It displays an astonishing amount of creativity and novel (at least to me) ideas, most of which are probably bad and won't survive for long, but some of them are really cool! Things like "packed loops"

    for i, j { println(list[i][j]) }
or using `return` as a variable without exiting

    return = 8
Really cool!
3 comments

> or using `return` as a variable without exiting

Also found in the Nim language (no affiliation/loyalty, just in case anyone is curious to see an existing use of this)

https://nim-lang.org/0.18.0/tut1.html#procedures-result-vari...

Many languages have return variables (e.g. Matlab far predates Nim), but this is the first time I saw the name/keyword return itself be used.
The name is 'result' not 'return'.
I seem to recall something similar in an old language (maybe Pascal?) where the way to return something was to assign it to the name of the function.
Fortran does this (still does in F2008). But usually I end up using subroutines instead, since I want the code in question to modify more than one object. Functions can only return one object, and the overhead of packing/unpacking to a struct is annoying.

What Fortran really needs to get is first-class string handling and saner IO. Apart from that being a pain, modern Fortran is a nice language to use.

Pascal you can set and return the "result" variable in a function without declaring it. You can also use the functions name to do the same
Julia also does loops with two indexes.
I think the point of packed loops is that the compiler/runtime figures out the bounds/ranges for each variable automatically.