lua-users home
lua-l archive

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




On Tue, Mar 13, 2018 at 10:49 PM, Russell Haley <russ.haley@gmail.com> wrote:


On Tue, Mar 13, 2018 at 10:39 PM, Russell Haley <russ.haley@gmail.com> wrote:


On Tue, Mar 13, 2018 at 10:32 PM, Russell Haley <russ.haley@gmail.com> wrote:


On Tue, Mar 13, 2018 at 10:19 PM, Russell Haley <russ.haley@gmail.com> 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 <chighland@gmail.com> wrote:
On Tue, Mar 13, 2018 at 11:39 PM, Russell Haley <russ.haley@gmail.com> wrote:
>
>
> On Tue, Mar 13, 2018 at 6:45 PM, Coda Highland <chighland@gmail.com> wrote:
>>
>> On Tue, Mar 13, 2018 at 7:47 PM, Tomás Guisasola
>> <tomas@tecgraf.puc-rio.br> 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?
>