[REBOL] Re: More dialects than you think, validating function input.
From: greggirwin:mindspring at: 12-Sep-2002 9:56
Brett, et al
A very good post, and related to the discussion on error handling to boot!
:)
I can see at least two major ways to apply this approach.
1) Parse drives the processing of the function, automatically validating the
correctness of the argument block as it goes.
2) Parse is used only to validate the block at the entry point, like a
precondition in a Design by Contract design, and the operation of the
function is separate. You could also use parse to validate return values
(i.e. as a post-condition processor).
In a large system, and as more things are driven by dialects, this could
prove very useful indeed. Now, does anyone have a model they use to return
helpful context information when a parse operation fails? Programmers are OK
with "Syntax error: expected integer!" but users are probably better served
by "I understood the first part ("sell 400 shares of MSFT at"), but then I
was expecting to see a monetary value for the sell price (e.g. $50.00), and
I didn't, so I couldn't process your request. I'm sorry for any
inconvenience this might cause you. Have a nice day." Or maybe just "No sell
price was specified in your request." or even a prompt for the missing info.
In any case, I agree that this is a good tool to keep in mind.
--Gregg