Re: Proposal for a (small) enhancement to the value() function.
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> Jun 26, 2007
- 773 views
Bernie Ryan wrote: > > CChris wrote: > > > > Currently, value(), defined in get.e, takes a sequence and returns {status > > code, > > value read}. > > The proposed enhancement is to return > > {status code, > > value read, > > number of characters read, > > number of leading whitespace characters}. > > > > This can be done at the cost of creating a duplicated, slightly modified > > copy > > of the internal Get() function, so that performance won't be affacted at > > all. > > get() won't be affected, since where() will give you most of the same > > information. > > > > Any thoughts? issues? other suggestions? > > > Chris: > > I would rather that value() function just return the value > instead of sequence. The failure should fail within function with > a message. In my experience of using the value() I have never taken > taken any other action to the failure of the function except report > the error and end my program. Why should a user have to write extra > testing code just to use a basic function. This testing becomes a > pain in the neck especially if do a great number of calls to value(). > > Bernie > > My files in archive: > WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API > > Can be downloaded here: > <a > href="http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan">http://www.rapideuphoria.co m/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan</a> Try please
function simple_value(sequence s) s=value(s) if s[1]!=GET_SUCCESS then crash_message("Error reading a value") abort(1) else return s[2] end if end function
This could even be added to get.e, if it is felt to be useful. However, I don't like the idea of forcing a specific way to deal with errors inside a standard library. CChris