3 ms·
Pascal has nested functions and supports a limited form of closures. In Pascal, a function can be passed as an argument to another function, but cannot be stor
by weinzierl 15y ago
Pascal has nested functions and supports a limited form of closures.
In Pascal, a function can be passed as an argument to another function, but cannot be stored in a variable or data structure, cannot be returned from a function, and cannot be created without being given a name. However, when a function is passed to another function and later called, it will execute in the lexical context it was defined in, so it is, in some sense, "closed over" that context.
I also liked the I can pass parameters per value or reference without explicitly using pointers.
- guard-of-terra 15y agoIn C a function pointer can be passed around, and usually a pointer to contect structure is passed around. That happens to be more practical. References are cool. That makes one point for Pascal.
- barrkel 15y agoNested routines in classical Pascal support downwards funargs; they are closures lite, i.e. actually more expressive than C functions. But we are talking classical Pascal; every practical commercial Pascal implementation supports function pointers directly, just like C does.