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

[REBOL] Re: Version incompatibilities

From: gabriele:colellachiara at: 27-Nov-2005 12:48

Hi Sunanda, On Sunday, November 27, 2005, 11:59:41 AM, you wrote: Sac> But there are incompatibilities in versions of Core that need to be fixed Sac> first. A biggie is: Sac> my-object: make object! [field1: 1] Sac> if error? try[get in my-object 'field2] [ Sac> print "field2 does not exist" Sac> ] May I say, that coding style sometimes matters a lot. Even back then when GET did not accept NONE, I would have coded that as: either in my-object 'field2 [ my-object/field2 ] [ print "field2 does not exist" ] Throwing errors is always going to be more expensive, so I really tend to avoid doing that when I just want to do a check. (Of course, if you just wanted to delay the check, that's a different issue; but it's not the case above.) Anyway, a possible solution to your problem is:
>> get none
== none
>> remove back tail third third :get
== []
>> get none
** Script Error: get expected word argument of type: any-word object ** Near: get none which will give you back that error. Sac> my-object: make object! [field1: 1] ;; no field2 Sac> my-object: make object! [field1: 1; field2: none] ;; field2 is none Sac> my-object: make object! [field1: 1; field2: 2] ;; field2 is another value Note that if you checked the result of IN instead, you'd have no problems with any of those cases. Sac> Then, once we've identified the code that is affected by the change, we Sac> either: Sac> ** recode it to work correctly in all three conditions Sac> **continue to use the older Core for that script (if that is possible: the Sac> Library is highly modular, so two scripts calling each other may need different Sac> versions of Core) ** patch the current Core so that it behaves like the old one. ;) (In the few cases when you're not going to be able to do it, you'll have to fix the scripts.) Regards, Gabriele. -- Gabriele Santilli <> --- Colella Chiara software division ---