Name: Anonymous 2012-06-09 21:56
Help me /prog/, i'm making a language and i can't decide on what syntax to use for typed lambdas
square = lambda { |x| x * x }
/square {dup mul} def
(INT x)INT: x * x;
(INT x, y)INT: x + y;
INT: (INT i; read(i); i);
PROC f := (REF INT x)PROC REF INT: INT: x *:= 2;
INT i := 10;
PROC INT g = f(i);
MODE P = PROC(P)P;
# Y combinator: #
PROC y = (P f)P: ((P x)P: f((P v)P: x(x)(v))) ((P x)P: f((P v)P: x(x)(v)))(foo bat, baz).bar [:test, :argument]
var Y = function (F) {
return (function (x) {
return F(function (y) { return (x(x))(y);});
})
(function (x) {
return F(function (y) { return (x(x))(y);});
}) ;
} ;PROC y = (P f) P: (
(P x) P:
f((P v) P: x(x)(v))
)((P x) P:
f((P v) P: x(x)(v)))int *(*f(int* px))(void) {
int *g(void) { *px *= 2; return px; };
return g;
}
int n = 10;
int *(*pfpi)(void) = f(&n);
int *pi = f(&n)();
int i = *f(&n)();
printf("%d %d %d", *pfpi(), *pi, i);int*(*)(void), you use f(&n). If you want an int*, you use f(&n)(). If you want an int, you use *f(&n)().PROC f := (REF INT x)PROC REF INT: REF INT: x *:= 2;
INT n := 10;
PROC REF INT pri := f(n);
REF INT ri := f(n);
INT i := f(n);
print((pri, ri, i))PROC REF INT, a REF INT, or an INT, you use f(n).PROC f := (REF INT x)PROC REF INT: x *:= 2;INT:) equivalent in syntax and behavior to a function with no arguments that is called immediately. It was dropped because it was considered too complex for compilers to implement. To this day, no Algol 68 compiler has ever supported proceduring.