[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: documenting multiple returns (was reStructuredText (was ExpLua))
- From: Pedro Miller Rabinovitch <miller@...>
- Date: Thu, 23 Oct 2003 18:37:10 -0200
On Thursday 23 October 2003 11:12, RLake@oxfam.org.uk wrote:
> I apologise for not sending to the list, but my webmail has the wrong
> return address.
> This particular case is quite common, no? Perhaps you need some syntax
> for what a function does in the case of an error (maybe with an explanation
> of what constitutes an error). There are really only two standard ways of
> dealing with errors in Lua: either you "throw" an error, or you return nil
> and an error description.
You're quite correct. I couldn't come up with a different situation where
multiple kinds of return are used in at *least* 15 seconds. >: ) Any
situation like that is either
1) error treatment;
2) returning the type of object we got (i.e., any, or simple number|string);
3) something that ought to be refactored into two functions.
> So you could just abstract that information from the "normal return type",
> and say:
> --! (nil, message, filename, linenumber)
> --- If a syntax error is found
> --! will blow up if the index is nil
> The distinction being whether the first thing is an ( or not.
Yeah, that's very nice. I'll work that into the system when I have some time
> I like | for type union, myself. Although I would use more whitespace.
I'm not using it, but I do believe I've placed whitespace %s* masks in between
the parenthesis, so ( number | string ) should work just fine.
Regards and thanks for the input,