lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



A perl-ish way of making error checking, but neat and effective:

_= nsfm:fileExistsAtPath(testfile)
    or error "File doesn't exist!"

_= nsfm:copyPath( testfile, newfile )
    or error "File copy failed!"

Currently, Lua does not allow leaving the "_=" away, since that would make these commands and commands don't have a value ('or' gives this a value).

In my opinion, evaluation results could be allowed even if the value is not stored anyway. In a way, they would have a "drain" that eats up the value.

I do know that by a function this can be overcome, but the neaty is to have the essential thing first (the command), and ability to switch on/off the error check by simply commenting that out. Anyways, this is caused by my exposure to perl lately, it does show. Perl has a lot of those thisandthat or die things.. Which I actually like(d).

-asko