[ANN] Lua 5.4.0 (work1) now available

classic Classic list List threaded Threaded
164 messages Options
12345 ... 9
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Lua 5.4.0 (work1) now available

Dirk Laurie-2
2018-03-13 22:38 GMT+02:00 Rodrigo Azevedo <[hidden email]>:

> the (new) syntax could be extended to
> non-tables
>
> a = function(x) return x end
> a = undef

This is perfectly legal if a is global, since a=undef is equivalent to
_ENV.a = undef
It is an error if a is local, or if a does not in fact currently have a value.

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Lua 5.4.0 (work1) now available

Dirk Laurie-2
In reply to this post by Luiz Henrique de Figueiredo
> Lua 5.4.0 (work1)

_ARG seems not to have made it into the work version.

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Lua 5.4.0 (work1) now available

Albert Chan
In reply to this post by Dirk Laurie-2
On Mar 13, 2018, at 4:50 PM, Dirk Laurie <[hidden email]> wrote:

> 2018-03-13 22:38 GMT+02:00 Rodrigo Azevedo <[hidden email]>:
>
>> the (new) syntax could be extended to
>> non-tables
>>
>> a = function(x) return x end
>> a = undef
>
> This is perfectly legal if a is global, since a=undef is equivalent to
> _ENV.a = undef
> It is an error if a is local, or if a does not in fact currently have a value.
>

Based on above example, local variable can not set to undef ?

Is this (new) syntax for performance ? (less memory churn ?)

I don't fully get it.
If user do not want "holes" in table, false can be used instead of nil
the feature seems just a new mapping (false -> nil, nil -> undef)

(I thought false were introduced for removing holes in table)
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Lua 5.4.0 (work1) now available

Rena
In reply to this post by Roberto Ierusalimschy
On Tue, Mar 13, 2018, 15:44 Roberto Ierusalimschy, <[hidden email]> wrote:
> btw, I notice that there is a new keyword, "undef", not mentions in manual,
> is that just a undocumented feature or the doc just not the latest?

I am grad you asked :-)

Lua 5.4 has an experimental change that is off by default (to keep
compatibility). We plan to keep this off in Lua 5.4 final.
You can turn it on by compiling this version with the option
-DLUA_NILINTABLE. As the name hints, this option allows nils in tables:

>  t = {nil, nil, nil}
> #t
3
> for k,v in pairs(t) do print(k, v) end
1       nil
2       nil
3       nil
> t[#t + 1] = nil
> for k,v in pairs(t) do print(k, v) end
1       nil
2       nil
3       nil
4       nil


Once you have nils in tables, t[i]=nil does not remove elements from
a table anymore. For that, you need to write t[i]=undef.

No, this is not like JavaScript! 'undef' is NOT a value.

t[i]=undef is a special syntax form that means "remove the key 'i'
from table 't'". You can only use 'undef' in three specific forms:

  t[i] = undef     -- remove a key from a table
  t[i] == undef    -- test whether a table has a key
  t[i] ~= undef    -- test whether a table has a key

Any other use of 'undef' gives a syntax error.

You still can create tables with holes, but you must get out of your
way to do it.

The nice thing about this syntax is that it is compatible with
previous versions of Lua (as long as you do not use 'undef' for
other stuff). In Lua 5.0/1/2/3, if you write 't[i] = undef', you remove
the element from the table. Even if we never change Lua to this
new mode, even if you never use Lua 5.4, we think this syntax is
a nice way to document whether an assignment is being done to remove
an element from a table.

(A search for the pattern '][ =~]*nil' finds most of the places
in your code where you could/should use undef instead of nil.)

-- Roberto

So, how do we store 'undef' in a table? ;-)

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Lua 5.4.0 (work1) now available

Tomás Guisasola-2
In reply to this post by Roberto Ierusalimschy
Hi Roberto

No, this is not like JavaScript! 'undef' is NOT a value.
But it is used as a value.  It sounds strange to me...
 
t[i]=undef is a special syntax form that means "remove the key 'i'
from table 't'".
But it seems like an assignment.  Wouldn't be better to create a special syntax for removing a key from a table instead pretending it as an assingment?

You should have considered a pair of functions, such as table.undefine(t, i) to undefine a key, and table.defined(t, i) to check whether the table has the key.  Why did you choose the assignment?

Regards,
Tomás
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Lua 5.4.0 (work1) now available

Coda Highland
On Tue, Mar 13, 2018 at 7:47 PM, Tomás Guisasola
<[hidden email]> wrote:

> Hi Roberto
>
>> No, this is not like JavaScript! 'undef' is NOT a value.
>
> But it is used as a value.  It sounds strange to me...
>
>>
>> t[i]=undef is a special syntax form that means "remove the key 'i'
>> from table 't'".
>
> But it seems like an assignment.  Wouldn't be better to create a special
> syntax for removing a key from a table instead pretending it as an
> assingment?
>
> You should have considered a pair of functions, such as table.undefine(t, i)
> to undefine a key, and table.defined(t, i) to check whether the table has
> the key.  Why did you choose the assignment?
>
> Regards,
> Tomás

Functions are a bad idea, because this really is a language primitive.

That said, I would have preferred a keyword operator ("delete x")
instead of a syntactic constant-ish thing. I understand why it wasn't
done -- it simplifies the grammar because it's not a new token type,
just a special case in the existing grammar, and it's mostly
backwards-compatible if you turn the feature off.

/s/ Adam

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Lua 5.4.0 (work1) now available

Daurnimator
In reply to this post by Luiz Henrique de Figueiredo
On 14 March 2018 at 02:43, Luiz Henrique de Figueiredo
<[hidden email]> wrote:
> All feedback welcome. Thanks.

I get a few warnings with gcc 7.3.0.
The LUA_USE_JUMPTABLE one has already been reported elsewhere in this thread.


gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_LINUX
-c -o lcode.o lcode.c
In file included from lcode.h:12:0,
                 from lcode.c:19:
lcode.c: In function ‘luaK_finish’:
lopcodes.h:108:30: warning: this statement may fall through
[-Wimplicit-fallthrough=]
 #define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \
                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   ((cast(Instruction, o)<<POS_OP)&MASK1(SIZE_OP,POS_OP))))
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lcode.c:1698:9: note: in expansion of macro ‘SET_OPCODE’
         SET_OPCODE(*pc, OP_RETURN);
         ^~~~~~~~~~
lcode.c:1701:7: note: here
       case OP_RETURN: case OP_TAILCALL: {
       ^~~~
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_LINUX
-c -o lgc.o lgc.c
lgc.c: In function ‘reallymarkobject’:
lgc.c:297:25: warning: this statement may fall through [-Wimplicit-fallthrough=]
     case LUA_TUSERDATA: {
                         ^
lgc.c:306:5: note: here
     case LUA_TLCL: case LUA_TCCL: case LUA_TTABLE:
     ^~~~
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_LINUX
-c -o lvm.o lvm
lvm.c: In function ‘luaV_execute’:
lvm.c:884:5: warning: this use of "defined" may not be portable
[-Wexpansion-to-defined]
 #if LUA_USE_JUMPTABLE
     ^~~~~~~~~~~~~~~~~

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Lua 5.4.0 (work1) now available

Russell Haley
In reply to this post by Coda Highland


On Tue, Mar 13, 2018 at 6:45 PM, Coda Highland <[hidden email]> wrote:
On Tue, Mar 13, 2018 at 7:47 PM, Tomás Guisasola
<[hidden email]> wrote:
> Hi Roberto
>
>> No, this is not like JavaScript! 'undef' is NOT a value.
>
> But it is used as a value.  It sounds strange to me...
>
>>
>> t[i]=undef is a special syntax form that means "remove the key 'i'
>> from table 't'".
>
> But it seems like an assignment.  Wouldn't be better to create a special
> syntax for removing a key from a table instead pretending it as an
> assingment?
>
> You should have considered a pair of functions, such as table.undefine(t, i)
> to undefine a key, and table.defined(t, i) to check whether the table has
> the key.  Why did you choose the assignment?
>
> Regards,
> Tomás

Functions are a bad idea, because this really is a language primitive.

Can I ask why this would be considered a primitive and not just a behaviour of tables?
If it were a function it could be re-assigned and used as a check for any bounds value or "tomb stone". It would potentially also be valid in both normal and LUA_NILINTABLE mode.

Cheers,
Russ

That said, I would have preferred a keyword operator ("delete x")
instead of a syntactic constant-ish thing. I understand why it wasn't
done -- it simplifies the grammar because it's not a new token type,
just a special case in the existing grammar, and it's mostly
backwards-compatible if you turn the feature off.

/s/ Adam


Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Lua 5.4.0 (work1) now available

Coda Highland
On Tue, Mar 13, 2018 at 11:39 PM, Russell Haley <[hidden email]> wrote:

>
>
> On Tue, Mar 13, 2018 at 6:45 PM, Coda Highland <[hidden email]> wrote:
>>
>> On Tue, Mar 13, 2018 at 7:47 PM, Tomás Guisasola
>> <[hidden email]> wrote:
>> > Hi Roberto
>> >
>> >> No, this is not like JavaScript! 'undef' is NOT a value.
>> >
>> > But it is used as a value.  It sounds strange to me...
>> >
>> >>
>> >> t[i]=undef is a special syntax form that means "remove the key 'i'
>> >> from table 't'".
>> >
>> > But it seems like an assignment.  Wouldn't be better to create a special
>> > syntax for removing a key from a table instead pretending it as an
>> > assingment?
>> >
>> > You should have considered a pair of functions, such as
>> > table.undefine(t, i)
>> > to undefine a key, and table.defined(t, i) to check whether the table
>> > has
>> > the key.  Why did you choose the assignment?
>> >
>> > Regards,
>> > Tomás
>>
>> Functions are a bad idea, because this really is a language primitive.
>
>
> Can I ask why this would be considered a primitive and not just a behaviour
> of tables?
> If it were a function it could be re-assigned and used as a check for any
> bounds value or "tomb stone". It would potentially also be valid in both
> normal and LUA_NILINTABLE mode.
>
> Cheers,
> Russ

Given that tables are the fundamental compound data type of Lua,
there's not a whole lot of distinction. I would consider this to be
akin to rawset, which I also consider to be a primitive operation.
Perhaps it could be superficially a function instead of a keyword, but
it's still effectively a language builtin.

/s/ Adam

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Lua 5.4.0 (work1) now available

Russell Haley
Hi Lua Team, 

When compiled as normal and run through the VS 2017 debugger I get a kernelbase exception when I hit Ctrl+C. I don't get that in 5.1 or 5.3. 

"Exception thrown at 0x00007FFEDA4CFA2B (KernelBase.dll) in lua.exe: 0x40010005: Control-C. occurred"

In don't have kernelbase.pdb handy so I can't give you too much more (get it? Cause the OS is Binary? lolz! Oh Visual Studio, you are such a comedian.). :-/  

Also if I just type undef in the interpreter it waits for more input:

Lua 5.4.0 (work1)  Copyright (C) 1994-2018 Lua.org, PUC-Rio
> undef
>>

Just reporting that in case it's unexpected.

On Tue, Mar 13, 2018 at 9:55 PM, Coda Highland <[hidden email]> wrote:
On Tue, Mar 13, 2018 at 11:39 PM, Russell Haley <[hidden email]> wrote:
>
>
> On Tue, Mar 13, 2018 at 6:45 PM, Coda Highland <[hidden email]> wrote:
>>
>> On Tue, Mar 13, 2018 at 7:47 PM, Tomás Guisasola
>> <[hidden email]> wrote:
>> > Hi Roberto
>> >
>> >> No, this is not like JavaScript! 'undef' is NOT a value.
>> >
>> > But it is used as a value.  It sounds strange to me...
>> >
>> >>
>> >> t[i]=undef is a special syntax form that means "remove the key 'i'
>> >> from table 't'".
>> >
>> > But it seems like an assignment.  Wouldn't be better to create a special
>> > syntax for removing a key from a table instead pretending it as an
>> > assingment?
>> >
>> > You should have considered a pair of functions, such as
>> > table.undefine(t, i)
>> > to undefine a key, and table.defined(t, i) to check whether the table
>> > has
>> > the key.  Why did you choose the assignment?
>> >
>> > Regards,
>> > Tomás
>>
>> Functions are a bad idea, because this really is a language primitive.
>
>
> Can I ask why this would be considered a primitive and not just a behaviour
> of tables?
> If it were a function it could be re-assigned and used as a check for any
> bounds value or "tomb stone". It would potentially also be valid in both
> normal and LUA_NILINTABLE mode.
>
> Cheers,
> Russ

Given that tables are the fundamental compound data type of Lua,
there's not a whole lot of distinction. I would consider this to be
akin to rawset, which I also consider to be a primitive operation.
Perhaps it could be superficially a function instead of a keyword, but
it's still effectively a language builtin.

/s/ Adam


Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Lua 5.4.0 (work1) now available

Russell Haley


On Tue, Mar 13, 2018 at 10:19 PM, Russell Haley <[hidden email]> wrote:
Hi Lua Team, 

When compiled as normal and run through the VS 2017 debugger I get a kernelbase exception when I hit Ctrl+C. I don't get that in 5.1 or 5.3. 

"Exception thrown at 0x00007FFEDA4CFA2B (KernelBase.dll) in lua.exe: 0x40010005: Control-C. occurred"

In don't have kernelbase.pdb handy so I can't give you too much more (get it? Cause the OS is Binary? lolz! Oh Visual Studio, you are such a comedian.). :-/  

Also if I just type undef in the interpreter it waits for more input:

Lua 5.4.0 (work1)  Copyright (C) 1994-2018 Lua.org, PUC-Rio
> undef
>>

Just reporting that in case it's unexpected.

Lua 5.4.0 (work1)  Copyright (C) 1994-2018 Lua.org, PUC-Rio
> undef = function() print('hello lua team') end
stdin:1: syntax error near '='
> type(undef)
stdin:1: 'undef' is not a value!!
> type(ipairs)
function
> type(type)
function
> type(_VERSION)
string
> type(for)
stdin:1: unexpected symbol near 'for'
>

Is your error message for undef just for the work release? I ask because it seems to me you've had to break your data types to fit this in. It's not a keyword, but it's not a data type either. Can you explain why this is really better than a table.remove(t,i) function or the prior suggestion by Tomas?

Turning LUA_NILINTABLE on shortly to play.

Also, thanks for the great language. 

Russ

On Tue, Mar 13, 2018 at 9:55 PM, Coda Highland <[hidden email]> wrote:
On Tue, Mar 13, 2018 at 11:39 PM, Russell Haley <[hidden email]> wrote:
>
>
> On Tue, Mar 13, 2018 at 6:45 PM, Coda Highland <[hidden email]> wrote:
>>
>> On Tue, Mar 13, 2018 at 7:47 PM, Tomás Guisasola
>> <[hidden email]> wrote:
>> > Hi Roberto
>> >
>> >> No, this is not like JavaScript! 'undef' is NOT a value.
>> >
>> > But it is used as a value.  It sounds strange to me...
>> >
>> >>
>> >> t[i]=undef is a special syntax form that means "remove the key 'i'
>> >> from table 't'".
>> >
>> > But it seems like an assignment.  Wouldn't be better to create a special
>> > syntax for removing a key from a table instead pretending it as an
>> > assingment?
>> >
>> > You should have considered a pair of functions, such as
>> > table.undefine(t, i)
>> > to undefine a key, and table.defined(t, i) to check whether the table
>> > has
>> > the key.  Why did you choose the assignment?
>> >
>> > Regards,
>> > Tomás
>>
>> Functions are a bad idea, because this really is a language primitive.
>
>
> Can I ask why this would be considered a primitive and not just a behaviour
> of tables?
> If it were a function it could be re-assigned and used as a check for any
> bounds value or "tomb stone". It would potentially also be valid in both
> normal and LUA_NILINTABLE mode.
>
> Cheers,
> Russ

Given that tables are the fundamental compound data type of Lua,
there's not a whole lot of distinction. I would consider this to be
akin to rawset, which I also consider to be a primitive operation.
Perhaps it could be superficially a function instead of a keyword, but
it's still effectively a language builtin.

/s/ Adam



Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Lua 5.4.0 (work1) now available

Russell Haley


On Tue, Mar 13, 2018 at 10:32 PM, Russell Haley <[hidden email]> wrote:


On Tue, Mar 13, 2018 at 10:19 PM, Russell Haley <[hidden email]> wrote:
Hi Lua Team, 

When compiled as normal and run through the VS 2017 debugger I get a kernelbase exception when I hit Ctrl+C. I don't get that in 5.1 or 5.3. 

"Exception thrown at 0x00007FFEDA4CFA2B (KernelBase.dll) in lua.exe: 0x40010005: Control-C. occurred"

In don't have kernelbase.pdb handy so I can't give you too much more (get it? Cause the OS is Binary? lolz! Oh Visual Studio, you are such a comedian.). :-/  

Also if I just type undef in the interpreter it waits for more input:

Lua 5.4.0 (work1)  Copyright (C) 1994-2018 Lua.org, PUC-Rio
> undef
>>

Just reporting that in case it's unexpected.

Lua 5.4.0 (work1)  Copyright (C) 1994-2018 Lua.org, PUC-Rio
> undef = function() print('hello lua team') end
stdin:1: syntax error near '='
> type(undef)
stdin:1: 'undef' is not a value!!
> type(ipairs)
function
> type(type)
function
> type(_VERSION)
string
> type(for)
stdin:1: unexpected symbol near 'for'
>

Is your error message for undef just for the work release? I ask because it seems to me you've had to break your data types to fit this in. It's not a keyword, but it's not a data type either. Can you explain why this is really better than a table.remove(t,i) function or the prior suggestion by Tomas?

Turning LUA_NILINTABLE on shortly to play.

Also, thanks for the great language. 

Russ

Okay, last one for tonight, I promise. With LUA_NILINTABLE, I would have expected to see an item indexed 3 with a value of nil in my output?

> t = {"one","two",nil,"four"}
> #t
4
> for i,v in pairs(t) do
>> print(i,v)
>> end
1       one
2       two
4       four

On Tue, Mar 13, 2018 at 9:55 PM, Coda Highland <[hidden email]> wrote:
On Tue, Mar 13, 2018 at 11:39 PM, Russell Haley <[hidden email]> wrote:
>
>
> On Tue, Mar 13, 2018 at 6:45 PM, Coda Highland <[hidden email]> wrote:
>>
>> On Tue, Mar 13, 2018 at 7:47 PM, Tomás Guisasola
>> <[hidden email]> wrote:
>> > Hi Roberto
>> >
>> >> No, this is not like JavaScript! 'undef' is NOT a value.
>> >
>> > But it is used as a value.  It sounds strange to me...
>> >
>> >>
>> >> t[i]=undef is a special syntax form that means "remove the key 'i'
>> >> from table 't'".
>> >
>> > But it seems like an assignment.  Wouldn't be better to create a special
>> > syntax for removing a key from a table instead pretending it as an
>> > assingment?
>> >
>> > You should have considered a pair of functions, such as
>> > table.undefine(t, i)
>> > to undefine a key, and table.defined(t, i) to check whether the table
>> > has
>> > the key.  Why did you choose the assignment?
>> >
>> > Regards,
>> > Tomás
>>
>> Functions are a bad idea, because this really is a language primitive.
>
>
> Can I ask why this would be considered a primitive and not just a behaviour
> of tables?
> If it were a function it could be re-assigned and used as a check for any
> bounds value or "tomb stone". It would potentially also be valid in both
> normal and LUA_NILINTABLE mode.
>
> Cheers,
> Russ

Given that tables are the fundamental compound data type of Lua,
there's not a whole lot of distinction. I would consider this to be
akin to rawset, which I also consider to be a primitive operation.
Perhaps it could be superficially a function instead of a keyword, but
it's still effectively a language builtin.

/s/ Adam




Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Lua 5.4.0 (work1) now available

Russell Haley


On Tue, Mar 13, 2018 at 10:39 PM, Russell Haley <[hidden email]> wrote:


On Tue, Mar 13, 2018 at 10:32 PM, Russell Haley <[hidden email]> wrote:


On Tue, Mar 13, 2018 at 10:19 PM, Russell Haley <[hidden email]> wrote:
Hi Lua Team, 

When compiled as normal and run through the VS 2017 debugger I get a kernelbase exception when I hit Ctrl+C. I don't get that in 5.1 or 5.3. 

"Exception thrown at 0x00007FFEDA4CFA2B (KernelBase.dll) in lua.exe: 0x40010005: Control-C. occurred"

In don't have kernelbase.pdb handy so I can't give you too much more (get it? Cause the OS is Binary? lolz! Oh Visual Studio, you are such a comedian.). :-/  

Also if I just type undef in the interpreter it waits for more input:

Lua 5.4.0 (work1)  Copyright (C) 1994-2018 Lua.org, PUC-Rio
> undef
>>

Just reporting that in case it's unexpected.

Lua 5.4.0 (work1)  Copyright (C) 1994-2018 Lua.org, PUC-Rio
> undef = function() print('hello lua team') end
stdin:1: syntax error near '='
> type(undef)
stdin:1: 'undef' is not a value!!
> type(ipairs)
function
> type(type)
function
> type(_VERSION)
string
> type(for)
stdin:1: unexpected symbol near 'for'
>

Is your error message for undef just for the work release? I ask because it seems to me you've had to break your data types to fit this in. It's not a keyword, but it's not a data type either. Can you explain why this is really better than a table.remove(t,i) function or the prior suggestion by Tomas?

Turning LUA_NILINTABLE on shortly to play.

Also, thanks for the great language. 

Russ

Okay, last one for tonight, I promise. With LUA_NILINTABLE, I would have expected to see an item indexed 3 with a value of nil in my output?

> t = {"one","two",nil,"four"}
> #t
4
> for i,v in pairs(t) do
>> print(i,v)
>> end
1       one
2       two
4       four

Sorry, my mistake, I didn't copy the DLL over after my rebuild. 

Russ
 
On Tue, Mar 13, 2018 at 9:55 PM, Coda Highland <[hidden email]> wrote:
On Tue, Mar 13, 2018 at 11:39 PM, Russell Haley <[hidden email]> wrote:
>
>
> On Tue, Mar 13, 2018 at 6:45 PM, Coda Highland <[hidden email]> wrote:
>>
>> On Tue, Mar 13, 2018 at 7:47 PM, Tomás Guisasola
>> <[hidden email]> wrote:
>> > Hi Roberto
>> >
>> >> No, this is not like JavaScript! 'undef' is NOT a value.
>> >
>> > But it is used as a value.  It sounds strange to me...
>> >
>> >>
>> >> t[i]=undef is a special syntax form that means "remove the key 'i'
>> >> from table 't'".
>> >
>> > But it seems like an assignment.  Wouldn't be better to create a special
>> > syntax for removing a key from a table instead pretending it as an
>> > assingment?
>> >
>> > You should have considered a pair of functions, such as
>> > table.undefine(t, i)
>> > to undefine a key, and table.defined(t, i) to check whether the table
>> > has
>> > the key.  Why did you choose the assignment?
>> >
>> > Regards,
>> > Tomás
>>
>> Functions are a bad idea, because this really is a language primitive.
>
>
> Can I ask why this would be considered a primitive and not just a behaviour
> of tables?
> If it were a function it could be re-assigned and used as a check for any
> bounds value or "tomb stone". It would potentially also be valid in both
> normal and LUA_NILINTABLE mode.
>
> Cheers,
> Russ

Given that tables are the fundamental compound data type of Lua,
there's not a whole lot of distinction. I would consider this to be
akin to rawset, which I also consider to be a primitive operation.
Perhaps it could be superficially a function instead of a keyword, but
it's still effectively a language builtin.

/s/ Adam





Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Lua 5.4.0 (work1) now available

Russell Haley


On Tue, Mar 13, 2018 at 10:49 PM, Russell Haley <[hidden email]> wrote:


On Tue, Mar 13, 2018 at 10:39 PM, Russell Haley <[hidden email]> wrote:


On Tue, Mar 13, 2018 at 10:32 PM, Russell Haley <[hidden email]> wrote:


On Tue, Mar 13, 2018 at 10:19 PM, Russell Haley <[hidden email]> wrote:
Hi Lua Team, 

When compiled as normal and run through the VS 2017 debugger I get a kernelbase exception when I hit Ctrl+C. I don't get that in 5.1 or 5.3. 

"Exception thrown at 0x00007FFEDA4CFA2B (KernelBase.dll) in lua.exe: 0x40010005: Control-C. occurred"

In don't have kernelbase.pdb handy so I can't give you too much more (get it? Cause the OS is Binary? lolz! Oh Visual Studio, you are such a comedian.). :-/  

Also if I just type undef in the interpreter it waits for more input:

Lua 5.4.0 (work1)  Copyright (C) 1994-2018 Lua.org, PUC-Rio
> undef
>>

Just reporting that in case it's unexpected.

Lua 5.4.0 (work1)  Copyright (C) 1994-2018 Lua.org, PUC-Rio
> undef = function() print('hello lua team') end
stdin:1: syntax error near '='
> type(undef)
stdin:1: 'undef' is not a value!!
> type(ipairs)
function
> type(type)
function
> type(_VERSION)
string
> type(for)
stdin:1: unexpected symbol near 'for'
>

Is your error message for undef just for the work release? I ask because it seems to me you've had to break your data types to fit this in. It's not a keyword, but it's not a data type either. Can you explain why this is really better than a table.remove(t,i) function or the prior suggestion by Tomas?

Turning LUA_NILINTABLE on shortly to play.

Also, thanks for the great language. 

Russ

Okay, last one for tonight, I promise. With LUA_NILINTABLE, I would have expected to see an item indexed 3 with a value of nil in my output?

> t = {"one","two",nil,"four"}
> #t
4
> for i,v in pairs(t) do
>> print(i,v)
>> end
1       one
2       two
4       four

Sorry, my mistake, I didn't copy the DLL over after my rebuild. 

Russ
 
On Tue, Mar 13, 2018 at 9:55 PM, Coda Highland <[hidden email]> wrote:
On Tue, Mar 13, 2018 at 11:39 PM, Russell Haley <[hidden email]> wrote:
>
>
> On Tue, Mar 13, 2018 at 6:45 PM, Coda Highland <[hidden email]> wrote:
>>
>> On Tue, Mar 13, 2018 at 7:47 PM, Tomás Guisasola
>> <[hidden email]> wrote:
>> > Hi Roberto
>> >
>> >> No, this is not like JavaScript! 'undef' is NOT a value.
>> >
>> > But it is used as a value.  It sounds strange to me...
>> >
>> >>
>> >> t[i]=undef is a special syntax form that means "remove the key 'i'
>> >> from table 't'".
>> >
>> > But it seems like an assignment.  Wouldn't be better to create a special
>> > syntax for removing a key from a table instead pretending it as an
>> > assingment?
>> >
>> > You should have considered a pair of functions, such as
>> > table.undefine(t, i)
>> > to undefine a key, and table.defined(t, i) to check whether the table
>> > has
>> > the key.  Why did you choose the assignment?
>> >
>> > Regards,
>> > Tomás
>>
>> Functions are a bad idea, because this really is a language primitive.
>
>
> Can I ask why this would be considered a primitive and not just a behaviour
> of tables?
> If it were a function it could be re-assigned and used as a check for any
> bounds value or "tomb stone". It would potentially also be valid in both
> normal and LUA_NILINTABLE mode.
>
> Cheers,
> Russ

Given that tables are the fundamental compound data type of Lua,
there's not a whole lot of distinction. I would consider this to be
akin to rawset, which I also consider to be a primitive operation.
Perhaps it could be superficially a function instead of a keyword, but
it's still effectively a language builtin.

/s/ Adam





Okay, this is definitely using the new functionality, but it seemed to remove an extra item by the end (I expected 4 but got 3)?

Lua 5.4.0 (work1)  Copyright (C) 1994-2018 Lua.org, PUC-Rio
> t = {"one","two",nil,"four"}
> #t
4
> for i,v in pairs(t) do
>> print(i,v)
>> end
1       one
2       two
3       nil
4       four
> #t
4
> t[3] = undef
> for i,v in pairs(t) do
>> print(i,v)
>> end
1       one
2       two
4       four
> #t
4
> table.remove(t,3)
nil
> #t
3
> for i,v in pairs(t) do print(i,v) end
1       one
2       two
3       four
> t[4] = nil
> t[5] = "five"
> for i,v in pairs(t) do print(i,v) end
1       one
2       two
3       four
4       nil
5       five
> u = table.move(t,1,#t,1,{})
> for i,v in pairs(u) do print(i,v) end
1       one
2       two
3       four
4       nil
5       five
> #t
5
> t[4] = undef
> for i,v in pairs(t) do print(i,v) end
1       one
2       two
3       four
5       five
> #t
3  --<<<<<< I Expected 4 here?
>
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Lua 5.4.0 (work1) now available

Andrew Gierth
In reply to this post by Luiz Henrique de Figueiredo
>>>>> "Luiz" == Luiz Henrique de Figueiredo <[hidden email]> writes:

 Luiz> All feedback welcome. Thanks.

Building on freebsd doesn't work without adding CC=cc (since gcc is not
installed by default and if you install it from ports, it's usually
under a version-specific name such as gcc6), and also enabling readline
requires adding -I/usr/local/include and -L/usr/local/lib, or tweaking
things to use libedit instead.

I've tried these, which all seem to work on my system (though obviously
the presence of a port build would make this somewhat moot):

# with base system libedit:
freebsd:
        $(MAKE) $(ALL) CC="cc" SYSCFLAGS="-DLUA_USE_LINUX -DLUA_USE_READLINE -I/usr/include/edit" SYSLIBS="-Wl,-E -ledit"

# ... with readline from ports:
freebsd-readline:
        $(MAKE) $(ALL) CC="cc" SYSCFLAGS="-DLUA_USE_LINUX -DLUA_USE_READLINE -I/usr/local/include" SYSLIBS="-Wl,-E -L/usr/local/lib -lreadline"

# ... with editing disabled
freebsd-noedit:
        $(MAKE) $(ALL) CC="cc" SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E"

and speaking of readline, it would still be good for lua.c to set
rl_readline_name and (maybe) rl_inhibit_completion as discussed
recently.

--
Andrew.

Reply | Threaded
Open this post in threaded view
|

Re: Re: [ANN] Lua 5.4.0 (work1) now available

Alex Queiroz
In reply to this post by Coda Highland
Hallo,

On 14/03/18 02:45, Coda Highland wrote:

> On Tue, Mar 13, 2018 at 7:47 PM, Tomás Guisasola
> <[hidden email]> wrote:
>> Hi Roberto
>>
>>> No, this is not like JavaScript! 'undef' is NOT a value.
>>
>> But it is used as a value.  It sounds strange to me...
>>
>>>
>>> t[i]=undef is a special syntax form that means "remove the key 'i'
>>> from table 't'".
>>
>> But it seems like an assignment.  Wouldn't be better to create a special
>> syntax for removing a key from a table instead pretending it as an
>> assingment?
>>
>> You should have considered a pair of functions, such as table.undefine(t, i)
>> to undefine a key, and table.defined(t, i) to check whether the table has
>> the key.  Why did you choose the assignment?
>>
>> Regards,
>> Tomás
>
> Functions are a bad idea, because this really is a language primitive.
>

I don't see how that follows.

I agree the assignment syntax is confusing, for the dubious benefit that
it *may* assign `nil` and thus remove the value from the table in older
versions of Lua.

Cheers,
--
-alex
http://unendli.ch/

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Lua 5.4.0 (work1) now available

Axel Kittenberger
In reply to this post by Roberto Ierusalimschy
No, this is not like JavaScript! 'undef' is NOT a value.

Well semantically it is, but it's a great change nonetheless!

Finally 'nil' became a first class citizen.

't[ i ] = undef' is semantically equal to JS 'delete t[ i ];'

"undefined" in Javascript better corresponds to "nil" in Lua, and "null" in JS is a completely nonsense singleton best just never used.

I was recently biten by current behaviour, because of a list being shorter than intended due to a spelling mistake in the last entry, evaluated to nil and no way in the callee of checking it was nil by accident.

Now after all the years Lua greatly improved on this, I feel affirmed just having to lean back and wait a little more and a version or two downward we'll also have 0-based indexing by default as option :-)

Kind regards,


Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Lua 5.4.0 (work1) now available

Scott Morgan
In reply to this post by Roberto Ierusalimschy
On 03/13/2018 07:43 PM, Roberto Ierusalimschy wrote:
>> btw, I notice that there is a new keyword, "undef", not mentions in manual,
>> is that just a undocumented feature or the doc just not the latest?
>
> I am grad you asked :-)
...
> t[i]=undef is a special syntax form that means "remove the key 'i'
> from table 't'". You can only use 'undef' in three specific forms:
>
>   t[i] = undef     -- remove a key from a table
>   t[i] == undef    -- test whether a table has a key
>   t[i] ~= undef    -- test whether a table has a key
>
> Any other use of 'undef' gives a syntax error.

So you couldn't do:

function foo()
  return undef
end

t[i] = foo()
t[i] = bar or undef

Still, very interesting feature idea.

Scott

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Lua 5.4.0 (work1) now available

Xavier Wang
In reply to this post by Luiz Henrique de Figueiredo

All feedback welcome. Thanks.
--lhf

There are two functions both named "pack" in ltablib.c and  lmathlib.c, makes amalgamation build not possible.

--
regards,
Xavier Wang.
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Lua 5.4.0 (work1) now available

Luiz Henrique de Figueiredo
> There are two functions both named "pack" in ltablib.c and  lmathlib.c,
> makes amalgamation build not possible.

Indeed. This does not show in 64-bit platforms but does show with
"make c89". Thanks for the report.

12345 ... 9