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

Set-words and refinements

 [1/4] from: rebol::svendx::dk at: 15-Nov-2000 1:09


Hello Brett On 14-Nov-00, you wrote: -- snip --
> 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
<<quoted lines omitted: 7>>
> Then mydate could utilise the same set-word syntax as the date datatype. > Waddya reckon?
I've been wanting to try something like PYRO (PYthon Remote Objects) in REBOL, but the syntax keeps getting ugly, like: my-remote-object/set-attr 'attr-name "value" instead of: my-remote-object/attr-name: "value" For more information about PYRO: http://www.xs4all.nl/~irmen/python.html In general, I belive REBOL would benefit by looking a bit at how Python allows objects to act like any(?) other datatype; lists, files, numbers, etc.
> Brett. >
Best regards Thomas Jensen

 [2/4] from: brett:codeconscious at: 14-Nov-2000 21:26


In the "add/subtract with dates" thread Jim Goodnow II suggested the following date/month: date/month + 1 I must have my eyes closed, or a part of my brain just filtered away this for me so far - it was quite a suprise. In Delphi I'd think "oh I see, date is a class with a property called month which when set invokes a method to change the date and when accessed invokes a method to return the month". But this is Rebol and while I understand that date is a native datatype and thus perhaps treated specially by the interpreter I was still suprised. Two questions 1) Any more of these?! 2) Can I build an object that behaves like that? And if not, then RT, could I could I please please..? It looks kinda cool. Brett --
>> my-rebol-stuff
== http://www.codeconscious.com/

 [3/4] from: al:bri:xtra at: 14-Nov-2000 23:50


Brett wrote:
> 1) Any more of these?!
It extends to strings as well:
>> s: "mary had a little lamb"
== "mary had a little lamb"
>> s/10: #"X"
== "mary had X little lamb" Blocks, too:
>> b: [print "hello"]
== [print "hello"]
>> b/1: 'prin
== [prin "hello"]
> 2) Can I build an object that behaves like that? And if not, then RT,
could I could I please please..? It looks kinda cool. And with objects as well:
>> o: make object! [
[ m: 123 [ ]
>> o/m
== 123
>> o/m: 456
== 456
>> probe o
make object! [ m: 456 ] Much easier than other popular scripting languages. Andrew Martin ICQ: 26227169 http://members.nbci.com/AndrewMartin/

 [4/4] 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.

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted