Re: Proposal for a (small) enhancement to the value() function.
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> Jun 25, 2007
- 741 views
Juergen Luethje 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? > > CChris > > Why? > > Regards, > Juergen Because, when you wish to process text, you have to search for some free format stuff and replace only the exact right portion by something. value() currently does not return the information, but it is hidden in local vars in get.e. The idea is simply to make the extra information available, as it is sometimes useful. I have quite often wished I didn't have to code my own version of value() for that purpose. If the "why?" refers to the duplicate modified Get(), it stems from the fact that Get() recursively calls itself, while only the first called instance needs to report the extra information. Hence, the original function handles the innermost calls, and the outer one returns the extra data. That's why two slightly different functions are needed if you wish to avoid too many flag tests and useless calls to aux routines. For translated code, the compiler will inline smartly enough for this not to be necessary, but interpreted code could benefit. CChris