[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: string.byte returning nothing (Re: Changelog for 5 - 3/3/2003)
- From: Dimiter 'malkia' Stanev <malkia@...>
- Date: Wed, 21 Mar 2012 10:33:33 -0700
Bringing this one out of the dead.
At some point it was considered that string.byte would return nil
instead of nothing. For example type((''):byte()) bombs now.
- string.byte returns nil for index out-of-range
What was the consensus for keeping the current implementation.
I'm just curious. It's just a matter of better learning for me.
For example:
local a,b,c=(''):byte(),1,2
print(a,b,c)
# nil 1 2
I would've thought this should be
# 1 2 nil
P.S. There is one more peculiarity:
# Note the coma at the end
local a,b,c=('ab'):byte(1,2),
print(a,b,c)
# nil nil nil
Thanks!
On 3/3/2003 3:16 PM, Roberto Ierusalimschy wrote:
Quick list of changes from 4.0 to 5.0:
- coroutines
- lexical scoping
- metatables (x tags)
- weak tables
- generic for
- proper tail call
- boolean type
- new way to handle userdata in the C API (+ light userdata)
- new way to handle errors in the C API
- new functions (time/date, tmpfile, unpack, require, load*, )
- block comments --[[...]]
- still faster
- better error messages
Quick list of changes from 5.0 beta to final:
- no-nonsense debug info about tail calls
- correct implementation for comparison metamethods
- getn/setn in lauxlib
- two new debug functions to manipulate upvalues
- string.byte returns nil for index out-of-range
- "require" returns value returned by package
- get/setglobals renamed to get/setfenv ("function environment")
-- Roberto