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

[REBOL] Re: Load of trouble?

From: brett:codeconscious at: 30-Nov-2001 12:26

Hi Colin, <skipped instructive comments>
> But using 'load at all introduces a subtle problem. Each 'load of a
raw-input
> string potentially adds entries to System/Words. When that reaches about > 4000, the system crashes. Unrecoverably. > > Which means the code above can't be 24x7 on a server. And it won't last
more
> than a few hundred lines if it's part of a clean-up operation on an
incoming
> text file.
True. However, Romano has shown that TO-BLOCK can be used instead of LOAD to avoid flooding system/words.
> So (my conclusion) is that 'load for validation of raw data is a dead end.
I'm thinking I agree.
> And if I'm going to continue using Rebol, I need to buckle down and write > some serious data validation code first. Or RT need to rethink
System/Words. Serious validation code, but not too onerous. I took your idea of using TRY, added in Romano's on using TO-BLOCK, and mixed in my own by using PARSE for validation. Poured into a function and cooked for 5 minutes: accept-date: function [raw-input] [cleared-input] [ if error? try [ either parse to-block raw-input [set cleared-input date!] [ RETURN cleared-input ] [throw make error! "Not a valid date!"] ] [cleared-input: none] ] The above function returns none if it doesn't like what it sees, otherwise it returns a date:
>> accept-date " W1a 4AA "
== none
>> accept-date " 27-may-01"
== 27-May-2001 Ok It is not a one-liner, but with more thought maybe it could handle more basic types than just date therefore justifying it's bulk. And if you want to accept date formats where like "27 may 2001" then parse will be your friend. HTH Brett [part time Parse evangelist :) ]