[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Noob question -- On error, exit function and terminate script
- From: Lorenzo Donati <lorenzodonatibz@...>
- Date: Sat, 25 Jun 2011 21:19:43 +0200
On 25/06/2011 20.35, marbux wrote:
On Sat, Jun 25, 2011 at 7:12 AM, Rebel Neurofog<firstname.lastname@example.org> wrote:
assert () is the best in your case (more verbose)
Thank you, Rebel, and the others who responded; assert works for my use case.
BTW, I suggest that Reference Manual section 5.1 be amended to
indicate that assert and error will cause termination of the script
when their evaluations indicate an error condition. That information
is currently not included in their respective documentation sections.
I must nevertheless admit that the description for assert is slightly vague:
"Issues an error when the value of its argument v is false (i.e., nil or
I'll suggest to change it to:
"Calls the function 'error' when the value of its argument v is false
(i.e., nil or false);..."
So that one avoids being mislead to think that the error mechanism could
be different from that of "error".
This is not nitpicking, since assertions in Java and other languages
aren't part of the normal error management system, unlike in Lua.
Maybe a less misleading name should have been chosen ("ensure", "test",
"check" as in the C API?), but now it's too late.