Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: Functional programming in REBOL

From: lmecir:mbox:vol:cz at: 12-Aug-2001 9:46

Hi Larry,
> Your solutions for all three puzzles are correct. Here is one > more combinator which is more difficult to explain (at least for myself): > > ???: cfunc [f][ > do > cfunc [x][f func [y][do x :x :y]] > cfunc [x][f func [y][do x :x :y]] > ] > > What does the function ??? do? And what requirements must its function > argument meet in order to guarantee that it produces a result? > > Cheers > -Larry > > PS This is one where I thought perhaps cfunc and this whole approach to > functional programming in REBOL would break down, but it seems to work
> fine.
Very interesting! The ??? function looks like an impersonalized Russell'd paradox. I didn't know about such functions until now. If I define: id: func [x] [:x] then the result: beast: ??? :id is pretty well defined. The problem is, that the BEAST function is a function of one argument, but the result of its evaluation is totally undefined. In Rebol the expression: beast 1 Produces only stack overflow, but that is the best thing we can expect. If F supplied as an argument to ??? tried to evaluate its argument e.g. like: f: func [x] [x 1 0] Then, although the result of F should be 0 for X being a function taking one argument, the result of ??? :f cannot be evaluated. Similarly any attempt to supply a function evaluating its argument or any attempt to allow such an evaluation later cannot produce a sensible result, because ??? is a self-referencing definition. Nice indeed.