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

[REBOL] Re: Rebol interpreter bug with comparison of dates

From: al:bri:xtra at: 4-Dec-2002 16:24

Jan wrote:
> Personally, I don't mind such a behaviour, which disallows comparison of
apples to oranges. But I think the definition of (<) is too broad: it should be more specific - narrowed down to the orderable things, such as numbers, dates, but not points, etc. However, since the arguments of this operator are untyped, the "help <" suggests that one can compare anything to anything - and hence those unpleasant runtime surprises. I prefer being able to compare any-value with any-value. I think it's more versatile, as it enables one to write 'find -like functions that can find values in a series and not have to type check first. Here's an example that I was working on today (and where I found the problem): Find-Range: function [Ranges [block!] Value [any-type!] /Strict] [Range] [ repeat Index length? Ranges compose [ ; 'Compose adds more comparisons! Range: Ranges/:Index if all [Value >= Range/1 Value <= Range/2] [ return at Ranges Index ] ( if not Strict [ [ if Value < Range/1 [ return at Ranges max 1 Index - 1 ] if all [ Value > Range/2 Index >= length? Ranges ] [ return at Ranges Index ] ] ] ) ] ] ; The following is normally in a separate file: save %Term.r [; First and Last dates for each term. [28/Jan/2002 28/Mar/2002] [15/Apr/2002 28/Jun/2002] [15/Jul/2002 20/Sep/2002] [ 7/Oct/2002 6/Dec/2002] ] Term: first Find-Range load %Term.r now/date First_day_of_Term: first Term Last_day_of_Term: last Term Which finds the current (school) term for the current date (with allowance for a date before or after the individual terms). Andrew Martin ICQ: 26227169