[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: dostring that aborts on errors?
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Tue, 23 Oct 2001 11:00:45 -0200 (EDT)
>How do I write a "non-trapping" version of the "dostring" function
>that will propagates errors instead of just returning a nil and an error
>string? The default behaviour is that this code
A simple C solution is to change passresults in lbaselib.c to do this.
This solution has the advantage that it will work for bith dostring and dofile.
A simple Lua solution is this:
if arg==nil and type(arg)=="string" then error() end
return arg,arg,arg,arg,arg -- lazy!
The line marked "lazy" above should be replaced by a series of ifs no arg.n,
or by "return unpack(arg)" if you're using 4.1. If you're using 4.0, then you
can just copy the implementation of unpack in lbaselib.c from 4.1-alpha.