Re: [stack] Re: Barebone implementation of concatenative language in c or c++
John Nowak <[email protected]> Wed, 21 Jul 2010 00:11:10 -0400
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
On 2010.07.20, at 11:18 PM, Don Groves wrote: > Isn't call-by-reference essentially equivalent to lazy evaluation? Nope. Call-by-reference is an abomination that shouldn't exist. Lazy evaluation is unrelated. A quick run through here should help: http://en.wikipedia.org/wiki/Evaluation_strategy Caveat: It is possible to have an eager yet non-strict language. Wikipedia conflates eagerness and strictness which is unfortunate, although most existing eager languages are indeed strict. The Id programming language is an example of an eager, non-strict language. Wikipedia is bad at precision. > In a call-by-value environment, It seems to me that incapsulating > all data in functions yields the same effect as call-by-reference. If you replace "call-by-reference" with "lazy evaluation" (or similar), then you're essentially right if your language has lambda abstractions under which evaluation does not occur until they're applied. Lazy evaluation will share the result of evaluating the parameter though if it is needed in multiple places. You have to manually memoize the function passed in to emulate this in an eager setting. Concatenative languages do not have lambda abstractions, but you can achieve a similar result by placing a function on the stack and lifting values into it (e.g. via Factor's misnamed 'curry' function; it really should be called 'partial-apply' or similar, although that's not exactly right either). - jn