lua-users home
lua-l archive

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


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.
> 
> It is a similar point of using '\0' instead of 0; it documents what you
> are doing.

I agree.  I think it best if source code describes what is being done,
not how it is being done.  Same reason I use if (foo == NULL) rather
than just if (foo).

(Of course, this opinion taken to the excess would suggest I should use
a functional programing language.  Sod that.)

B.