[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: state of the Lua nation on resource cleanup
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 11 Feb 2009 10:54:38 -0200
> I've got a project where I use pcall often to catch "errors" that are
> generated with error() when inconsistencies in data being read are
> found. I think it's a reasonable use of error/pcall (rather than, say
> passing back an error code through the chain of data reading functions),
> but it's not a case where enough has gone wrong that any resources are
> left hanging, so I don't need or wish for a full garbage collection and
> finalisation. I know nothing about the cost of such a collection, so I
> can't say whether I'd rather not have one.
In most languages, error handling are not supposed to be "fast". (This
means that "error"/"throw" may be slow, not "try"/"pcall"). You shold
not use errors to handle "normal" situations.