lua-users home
lua-l archive

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


On 6/7/12, Peter Cawley <lua@corsix.org> wrote:
> On Thu, Jun 7, 2012 at 3:02 PM, joao lobato <btnfdp.lobato@gmail.com>
> wrote:
>> You can't break out of that for-loop. Those kind of constraints shape
>> your
>> solutions in ways that can easily make them suboptimal both in
>> time/memory
>> and ease of reading.
>
> On the flip side, knowing that you cannot break out could make it
> easier to read. A general for-loop could do all sorts of odd things,
> so you (in general) need to read the entire body to understand what
> might happen. For more specialised / sugared types of loop, reading
> the header is sufficient to understand that nothing crazy is going to
> happen.
>
>

Yes, I had not considered that. However, I believe that is valid only
for "small" examples where unsurprising things are accomplished. I
guess one could very easily understand Quicksort defined as a list
expression. It's perfect to explain the algorithm to someone, but you
would not want to use it to sort a big list.