Hi Joel,

> I'd refactor the code to separate the behavior of an individual
>  watch (as an object with its own state) from the behavior of
>  the total collection of watches in existence at a given time

Thanks for the complete rewrite. It's always useful to get a completely 
different view on how to do something, and I hope that between us we've 
produced some functionality that is of use to others.
                
A few thoughts about the difference between object+functions and 
function+refinements, inspired by your rewrite.

Object+functions of course give a lot more room to breathe -- it is easier to 
have persistent variables in them than it is with function+refinements. 

>From the outside there is almost no difference between calling an 
object/function and a function/refinement. If I rewrote my code to be an 
object but with the same interface, you couldn't tell the difference from 
seeing the invocation:
  
>> unit-timer/start "A code unit"
  
I say _almost_ no difference for two reasons:

01 -- In the original code, an invocation without a refinement executes the 
code and returns False:
>> print unit-timer
== false

 If it was an object, invocating the object name alone returns the object:
>> print unit-timer
?object?

There is no implicit init code for a Rebol object.

02 -- Help Unit-timer in the original returns an "overview" plus help for 
each refinement. If Unit-timer were an object, there'd be no obvious place 
for the overview. And I don't know any easy way of getting help for a 
function embedded in an object  --

>> help watchmaker/start
watchmaker/start is a path

(This seems an obvious design oversight that RT could fix one day).


Objects of course don't just give more room to breathe, they open an 
opportunity to work in a quite different way. Your code is a good example of 
this in that it assigns the functionality to user variables. I'm not sure 
what this next example does to your collection and report-all, but if I want 
a timer than lives on between program runs, I can do it with your code:

LongTime: watchmaker/new "long-life"
Longtime/start
...
Longtime/stop
write %longtime.wat mold longtime
......
Longtime: do read %longtime.wat mold
longtime/start

(This would be more useful if the function worked across midnights)

One tiny question. You have a to-seconds function I just use to-decimal. Any 
significant difference there?


Thanks again for the rework,
Sunanda.
-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to