[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Some enhancements in table initializations
- From: Jonathan Castello <twisolar@...>
- Date: Tue, 21 Sep 2010 03:44:47 -0700
On Tue, Sep 21, 2010 at 3:19 AM, <pj@pjb.com.au> wrote:
> Geoff Leyland wrote:
You accidentally attributed this to the wrong person. :)
>> In most languages I've seen, it's uncommon to put multiple
>> stand-alone statements on the same line.
>
> Well, I do it quite a lot; e.g.
> i=1; j=1; k=1;
> where the three statements form a semantic unit. Just like in
> maths prose you might see: "In the x=1 y=3 case this becomes..."
>
> Or:
> param1 = string.byte(trackdata, i); i = i+1
> param2 = string.byte(trackdata, i); i = i+1
> where it's vital that the extraction of the parameter never gets
> separated from the increment of the index.
In Lua, the first case can be changed to "i, j, k = 1, 1, 1", but I
agree that that's useful in non-contrived situations.
With the second, I'm liable to miss the increment in a casual
read-through. In fact, I did until I read what you said after it. I'd
rather put the code in a function and call it that way, truly ensuring
that each operation is associated with an increment.
>> Why use a semicolon where a newline would do?
>
> It saves space on the screen, thus giving a better overview of
> the code while editing.
My point is that, as the primary "end-of-statement", I find the
newline works well. The semicolon can always be used in those cases
where you do want them on a single line. But I'm definitely not
suggesting that the newline be the only end-of-statement marker...
there are simply some places where a newline would not "do".
(At this point, I'm not really suggesting much at all anyways.)
~Jonathan