[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Syntax and redundancy
- From: Rici Lake <lua@...>
- Date: Tue, 30 Aug 2005 12:49:12 -0500
On 30-Aug-05, at 12:20 PM, Boyko Bantchev wrote:
On 8/30/05, Rici Lake <lua@ricilake.net> wrote:
Try:
DO(i, 0, 9,
    int j, k;
    j = 2 * i;
    k = i + 1;
    printf("i = %d, j = %d, k = %d\n", i, j, k);
);
Sure, can't use commas here.  Everything has its limitations,
and perfection is but a mirage :)
In this case, I'd have to write   int j; int k;  instead.
Leading to the likelihood of obscure compiler warnings with this 
construct.
Even so, let's contrast:
imac:~ rici$ cat c.test
#include "do.h"
DO(i, 0, 9,
  int j = 2 * i;
  int k = i + 1;
  printf("i = %d, j = %d, k = %d\n", i, j, k);
);
imac:~ rici$ cat lua.test
for i = 0, 9 do
  local j, k = 2 * i, i + 1
  print(string.format("i = %d, j = %d, k = %d", i, j, k))
end
imac:~ rici$ wc c.test lua.test
       6      30     112 c.test
       4      29     106 lua.test
OK, without the include it would have favoured C by 10 characters, but 
then I could have used a Lua header with:
  function printf(...)
    print(string.format(...))
  end
thereby saving about 13 characters in Lua.
Conclusion: concision is not the issue. The issue is personal taste. 
The "conciseness" of C is mostly illusory. :)
- References:
- Syntax and redundancy, Gavin Wraith
- Re: Syntax and redundancy, David Olofson
- Re: Syntax and redundancy, Rici Lake
- Re: Syntax and redundancy, Aaron Brown
- Re: Syntax and redundancy, Adrian Perez
- Re: Syntax and redundancy, Rici Lake
- Re: Syntax and redundancy, Boyko Bantchev
- Re: Syntax and redundancy, Rici Lake
- Re: Syntax and redundancy, Boyko Bantchev
- Re: Syntax and redundancy, Rici Lake
- Re: Syntax and redundancy, Boyko Bantchev