lua-users home
lua-l archive

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


> Extending a function beyond its natural domain of definition
> always sacrifices something.

sub( str, 0, nil ) can only extend sub( str, >0, nil ) or sub ( str, <0, nil ).

Currently you have:
(1)  sub( str, i>0, nil )   returns suffix of length=#str-i+1, or the empty string, if i is too big.
(2)  sub( str, i<0, nil )   returns suffix of length=-i, or str, if i too small.

So which definition do you choose for sub( str, i=0, nil )?

Returning str does not fit (1) nor (2). Returning the empty string fits only (2).

So I think there is no ambiguity in extending the domain to 0.
But please let me know If you have any counter-example.

   Jörg