16 Oct
2012
16 Oct
'12
11:25 a.m.
1. check for "stack underflow"; and/or
such things are dealt with
By assert, I mean: assert(inputstack[#inputstack], "Input stack should never be empty when toppath() is called.")
normally
if inputstack[#inputstack] == nil then assume path "." end
is good enough ...
Is "inputstack[#inputstack] == nil" ever supposed to happen? When reading from stdin, maybe... then, it is ok.
(assert might make sense in situation where otherwise a crash would occur, but that never happens here)
If it is not supposed to happen, then it would indicate a bug, and should be detected as early as possible. A "crash" is a special case of that. But this is a matter of taste... :-) Cheers, André Caldas.