Kevin wrote: >On 2/11/06, Jim Self <[EMAIL PROTECTED]> wrote: >> Kevin, >> What do you want to happen when the error is detected? > >I would want the function to have a chance to return a 'failure' value. > > >> Your third example would give a syntax error. I would expect this to be a >> programming >> error. > >Not really. In my debugger program, I have the ability, while >stepping through the program, to dump out arrays. My array-display >function takes a variable name (similar to the pRef in my example).
That little bit of additional context helps quite a bit in understanding what you are after here. Using a debugger and taking a global reference directly from user input qualifies in my mind as on-the-fly interactive programming, not typical production oriented applications usage. >It has been working well, until I accidentally passed it an invalid reference. > >>In my work, it seems that the standard error response of logging the error and >> halting (or dropping back to the MUMPS shell) is generally the best way to >> handle these >> kinds of errors, unless you can catch them much earlier (composition rather >> than use of >> the construct). >> >> If pRef is expected to be a literal global reference then a function to >> check its syntax >> would be pretty easy to write. >> > >In my case, it is supposed to be anything the user wants it to be, and >it is the job of the function to screen out erroneous input. Actually, the indirection in your example (set result=$g(@pRef)) is quite restricted. The value of pRef must be a variable reference (global or local). It could perhaps have an expression as a subscript rather than a literal string or number, but that's about all the variation allowed. Given the context, this type of error would be expected. Given the restricted syntax of the indirection checking the syntax of pRef would be pretty easy to do, but a special error trap that simply returns the error message from evaluating the indirection with a malformed pRef would be even easier and might well be the best general solution. Then again, actually checking the syntax would give you the chance to correct simple errors and to provide more precise feedback. --------------------------------------- Jim Self Systems Architect, Lead Developer VMTH Computer Services, UC Davis (http://www.vmth.ucdavis.edu/us/jaself) ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642 _______________________________________________ Hardhats-members mailing list Hardhats-members@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/hardhats-members