Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Algol 68 is God-tier

Name: Anonymous 2012-04-09 16:27

Hey /prog/, can your toy language do this?
MODE P = PROC (P) P;
P i = (P x) P : x;
P v = (P x) P : v;
P k = (P x) P : ((P x, y) P: x)(x, );
P s = (P x) P : ((P x, y) P: ((P x, y, z) P: x(z)(y(z)))(x, y, ))(x, );
P succ = s(s(k(s))(k));
PROC side effect = (PROC VOID f) P : ((PROC VOID f, P x) P : (f; x))(f, );
PROC church = (INT n) P : (P f := k(i); TO n DO f := s(s(k(s))(k))(f) OD; f);
PROC int = (P f) INT : (INT n := 0; f((P x) P : (n +:= 1; i))(i); n);
OP + = (P x, y) P : ((P x, y, z) P : ((P x, y, z, w) P : x(z)(y(z)(w)))(x, y, z, ))(x, y, );
succ(church(10))(side effect(VOID : print(("Hello, world!", new line))))(i);
print(int(succ(church(100) + church(20))))

Name: Anonymous 2012-05-28 18:18

Why don't any languages besides Algol 68 and Scheme and some other Lisp dialects make the syntax and usage for anonymous functions the same as for named functions?
In Algol 68, procedure denotations (literals) like (INT i)INT: 2 * i can be used anywhere a procedure of mode PROC(INT)INT can be used. You only need to give a value (procedures are values), variable or mode a name if it needs to refer to itself. A procedure denotation can be assigned or given a name with PROC double = (INT i)INT: 2 * i. Now you can write ((INT i)INT: 2 * i)(10) or double(10) and they will mean the same thing.
Most other languages have quirks and limitations with functions/procedures/methods compared to other data types. JavaScript and Perl don't use regular variable assignment syntax for creating named procedures. Ruby has blocks and lambdas and procs which are all different from methods created by def. C++ lambdas all have different types and can't be used as ordinary function pointers if they capture variables. Java needs inner classes to fake anonymous methods. Algol 68's syntax is more regular than any of those languages.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List