Hi Elan

Thanks for the comment. I agree. Actually, I am experimenting with trying to
implement Lisp (actually Scheme) programming techniques in REBOL. Capturing
state in a function is one of the basic techniques emphasized in Structure
and Interpretation of Computer Programs by Abelson and Sussman. I suspect
you know this book. Anyway, I found a version of 'tic and 'toc that I like
even better than version 3 below. It avoids the awkwardness of using
'compose and is easily generalized for more complex situations. It does not
seem to be hurt by 'recycle.

tic5: func [/local t] [
     t: now/time
     toc5: func [] [print ["elapsed time:" now/time - t]]
]

>> tic5 wait 5 recycle toc5
elapsed time: 0:00:05

What do you think?

Larry


----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 28, 1999 5:50 PM
Subject: [REBOL] Handy Timer Functions Re:


> Hi Larry,
>
> first comment, I like your version 3 best:
>
> >tic3: func [] [toc3: func [] compose/deep [print ["elapsed time:"
now/time -
> >(now/time)]]]
>
> This approach really makes good use of REBOL's abilities. While it looks
> trivial, I think that functions, which create functions, which in turn
> reflect some state at the time the "dynamic" function was created is an
> important technique for building smarter programs. In a different
> application the state embedded in the created function coould very well be
> more complicated and specific to the creating function then in your case.
> Imagine a whole chain of function-creating functions.
>
> Elan
>

Reply via email to