[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Must "attempt to get length of a number value" be an error?
- From: Dirk Laurie <dirk.laurie@...>
- Date: Thu, 9 May 2019 18:36:01 +0200
Op Do. 9 Mei 2019 om 15:45 het Coda Highland <chighland@gmail.com> geskryf:
> But the #n == 8 comment was never meant as anything more than a flippant remark.
My original motivation (not divulged in the post) was that invoking a
function to get the absolute value of a number is really a very
cumbersome way for something that can be done by the C ternary
operator.Therefore I looked around for a unary operator not yet
defined for type "number" and found that __len is the only candidate.
It's a ten-line patch to lvm.c:
534a535,544
> case LUA_TNUMINT: {
> lua_Integer n=ivalue(rb);
> setivalue(ra,n<0?-n:n);
> return;
> }
> case LUA_TNUMFLT: {
> lua_Number x=fltvalue(rb);
> setfltvalue(ra,x<0?-x:x);
> return;
> }
- References:
- Must "attempt to get length of a number value" be an error?, Dirk Laurie
- Re: Must "attempt to get length of a number value" be an error?, Andrew Starks
- Re: Must "attempt to get length of a number value" be an error?, Coda Highland
- Re: Must "attempt to get length of a number value" be an error?, Philippe Verdy
- Re: Must "attempt to get length of a number value" be an error?, Coda Highland
- Re: Must "attempt to get length of a number value" be an error?, Philippe Verdy
- Re: Must "attempt to get length of a number value" be an error?, Coda Highland
- Re: Must "attempt to get length of a number value" be an error?, Philippe Verdy
- Re: Must "attempt to get length of a number value" be an error?, Coda Highland
- Re: Must "attempt to get length of a number value" be an error?, Philippe Verdy
- Re: Must "attempt to get length of a number value" be an error?, Coda Highland
- Re: Must "attempt to get length of a number value" be an error?, Philippe Verdy
- Re: Must "attempt to get length of a number value" be an error?, Coda Highland