[stack] Re: Barebone implementation of concatenative language in c or c++
"pml060912" <[email protected]> Sat, 24 Jul 2010 11:04:51 -0000
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
--- In [email protected], Don Groves <dgroves@...> wrote: > > On 23 Jul 2010, at 02:56, pml060912 wrote: > > > --- In [email protected], Don Groves <dgroves@> wrote: . . . > >> Thanks. Do you feel your approach is equivalent to lazy evaluation? > > > > We had that discussion earlier, I think actually on this thread. I > > feel it works out like this:- > > > > - From the program's point of view, it is equivalent to lazy > > evaluation, because the behaviour it delivers is the same. > > > > - From the programmer's point of view, it is not, because he or she > > has to do something explicit to achieve it. Before the syntactic > > sugar, quite a bit is needed to get things like recursion and loops, > > but even though that cuts it down it still doesn't eliminate it. > > > > Taking all in all, I decided to document it as "change the behaviour > > to lazy evaluation", not to call it lazy evaluation as such. > > P.M.Lawrence. > > > > But if that behavior is built into the language, why does an > application programmer have to do anything explicit? It's not built into the language, in that sense, any more than the fact that a gear lever and clutch pedal in a car make it have an automatic transmission. Rather, there are keywords the programmer can use to get the indirection that gives lazy behaviour to the code built with them even though those indirection keywords work eagerly - just as the car can change gears, but only when the driver works the controls for that. It's not enough to code branches with IF (say), the programmer also needs to put FREEZE into keywords for each branch (or use the [ ] pair in inline code) and then use THAW to make use of whatever was frozen (maybe with some of that hidden in yet other keywords). IF by itself only delivers eager behaviour. The programmer has to make explicit use of the indirection to achieve lazy behaviour, since the default is eager. P.M.Lawrence.