Re: [stack] Re: Barebone implementation of concatenative language in c or c++
John Nowak <[email protected]> Wed, 21 Jul 2010 00:39:54 -0400
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
On 2010.07.21, at 12:18 AM, William Tanksley, Jr wrote: > In order to pass a function to a procedure, the function has to be > available as data. If it's not, you can't pass it. > > Now, if your language is lazy (or non-strict) this doesn't matter; you > can avoid executing the function by never mentioning its parameter on > an execution path. In an eager language without first-class functions, the language implementor can offer a special 'delay' form that creates a thunk at runtime. A 'force' function can later force the computation to occur. Since the only real semantic issue with introducing 'delay' is due to strictness (e.g. 'delay (4 / 0)' would not cause an error until forced even though '4 / 0' does immediately), it's a relatively uncomplicated addition from a theoretical perspective. > This allows languages that don't provide higher-order functions to still be very expressive. You'd still need some way to parameterize functions by other functions even if functions aren't available as data at runtime. OBJ is an excellent example of how to do parameterized programming without first-class functions. - jn