[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Portability of Lua
- From: William Ahern <william@...>
- Date: Wed, 1 May 2013 11:33:50 -0700
On Wed, May 01, 2013 at 10:36:12AM -0300, Roberto Ierusalimschy wrote:
> > You know it's a lost cause when you see code with `sizeof (char)', although
> > at least the developer gets props for trying.
>
> I strongly desagree with this view. I frequently use 'sizeof(char)',
> although I am very aware that this is 1 by definition. I think it helps
> both to document that you are computing sizes of things with chars (e.g.,
> strings) and to change char to some other type (e.g., wchar_t) if the
> need comes.
Ok. Understandtable. But personally I would prefer to see sizeof *object,
not sizeof (type), in such a case. And really I meant to refer to a
different kind of expression.
> It is a similar point of using '\0' instead of 0; it documents what you
> are doing.
Yep. It documents ones intent. I've taken flak for doing that (I use it
often). But far fewer people argue against it, as opposed to sizeof (char).