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

[REBOL] Re: Set-words and refinements

From: brett:codeconscious at: 14-Nov-2000 22:33

Oops. Sorry Andrew. I didn't make myself clear. Here's the example again. date/month: date/month + 1 handles year rollovers (at least forward) as in
>> date: now
== 14-Nov-2000/22:20:53+11:00
>> date
== 14-Nov-2000/22:20:53+11:00
>> date/month: date/month + 2
== 13
>> date
== 14-Jan-2001/22:20:53+11:00
>>
So the interesting bit to me is the rollover-handling functionality of dates during set-word. Let's say I wanted to create an object similar in functionality to the date datatype. At the moment I think that I would have to define a function set-month that would do the rollover handling. So my object would be set like mydate/set-month mydate/month + 1 Wouldn't it be nice if I could create my object and when I set a word in it using the normal set-word syntax it calls a function to handle the change instead of creating calling the setter function explicity Then mydate could utilise the same set-word syntax as the date datatype. Waddya reckon? Brett.