Re: Proposal for a (small) enhancement to the value() function.
Pete Lomax wrote:
>
> CChris wrote:
> > Could you explain, however, why this alternative scheme is preferable?
> I have now totally changed my mind and gone off on a complete tangent:
> optional
> parameters.
>
> If Eu had optional parameters, then:
> }}}
<eucode>
> integer errcode, chars_read, lead_space
> procedure value_info(sequence info)
> errcode = info[1]
> chars_read = info[2]
> lead_space = info[3]
> if errcode!=GET_SUCCESS then
> -- handle errors centrally...
> end if
> end procedure
> constant r_ve=routine_id("value_info")
>
> object r
> r=value("0",r_ve)
> if errcode!=GET_SUCCESS then
> -- ... or one at a time
> </eucode>
{{{
> If you call value() with one parameter it behaves as now, for legacy code.
> If you call value() with two parameters, the result is a single value like
> most
> people expect.
> Note that in this scheme, value_info() is always called, GET_SUCCESS or not.
>
> Since optional parameters are a way off, I now change my vote to adding a
> valueEx()
> routine which works as above.
>
> Regards,
> Pete
Certainly defaulted parameters are a welcome addition. I could recycle code from
idEu easily I think in order to achieve this result. They would enable to fold
find_from() and more extensions into find() as well.
But for now...
Of course I can introduce valueEx() to get the 4 element sequence.
Derek, will you comit your own code, or do you prefer my doing so with
appropriate credits?
CChris
|
Not Categorized, Please Help
|
|