[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Microlight
- From: steve donovan <steve.j.donovan@...>
- Date: Tue, 18 Dec 2012 17:04:32 +0200
On Tue, Dec 18, 2012 at 3:53 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> More readable. That is the key phrase.
>
> What I mean is that I can at first glance, with no need to refer to
> documentation, see what
> s={}; for k=1,#a do s[k]=-a[k] end
> does.
I used to make a spirited argument for defining macros in C like
FOR(i,n) precisely because any non-standard for loop would stand out
and make the reader think a little bit. That is, use the shortcut for
the no-brainer case i=0,..n-1 and otherwise write it out.
The problem is less pronounced in Lua because for-loop syntax is sane
and does not repeat the loop variable three times.
I quite like the suggestion that the standard placeholders in string
lambdas should be a,b,c... and so forth. This form reads in a very
straightforward way:
imap(arr,'-a') (or the object form arr:map '-a').
It's short, and the semantics are very well defined. If we _were_
doing something different then an explicit for-loop is appropriate.
Maps are going to be less efficient, and critical code needs to be
written out explicitly. But most code is not critical.
steve d.