[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: sunday afternoon whishlist
- From: Marc OMorain <marc.omorain@...>
- Date: Mon, 10 May 2010 17:05:00 +0300
> Could x[] be syntactic sugar for x[#x+1] ?
> It would make appending to lists so much nicer.
I would worry about the hidden performance implications of this. The
magic # operator performs a binary search of both storage parts of the
table, which is an O(log N) operation.
It would be nicer to have a general table insert function, that puts a
value into the table with some unspecified key that does not already
exist in the table, allowing the user to easily use a table like a
set.
On 9 May 2010 18:36, Klaus Ripke <paul-lua@malete.org> wrote:
> hi friends
>
>
> as it was a rather quiet time on lua-l recently
> and especially with regard to 5.2 whishes,
> I feel like reraising a few FAQs, forgive me.
>
>
> Could x[] be syntactic sugar for x[#x+1] ?
> It would make appending to lists so much nicer.
>
>
> Could indexing anything but a table, or at least indexing nil,
> return nil instead of throwing an error?
> I don't see why x.z conveniently gives nil, if there is no z in x,
> but x.y.z requires an extra check for x.y .
> This makes working with structures with lots of optional parts pretty
> tedious - and if it's external input, basically everything is optional.
>
> Really I'd love to see nil behave like an empty value of
> the expected type most of the time, Perl style.
>
> Does anybody rely on all these errors being raised?
> Wouldn't that be poor style anyway?
> If you really want that, there's stil assert to make that clear, no?
> Doesn't the fact that you use x in an index operation,
> concat, format %s or whatever whithout checking for nil
> pretty clearly state that you want that operation to work,
> somehow?
> I'd so love to get rid of all that (x or '') everywhere.
>
>
> best
> Klaus
>