>  Foo foo = (Foo) malloc(sizeof(*foo));
>? Does ANSI allow using sizeof on a variable declared on the
> same line?

Wouldn't sizeof(Foo) be safer here? At the logical time of the
call *foo points to undefined. Technically its not a deref but
still looks scary. In C++ it might be confusing if you were to
cast it as:

// If it were really C++ we would probably be using new()
Foo foo = (FooBar) malloc(sizeof(*foo));

What type is *foo then? Should be Foo, but what if FooBar
was of different size, it might not be an obvious bug to someone
that just came along and tweaked your code.

Not sure if I made any point here but it seemed interesting. :)

>and in the gazillion places where 'struct Parrot_Interp *'
>is used, we'd use 'Parrot_Interp' instead. Imagine, we'll save
>8 bytes * 1 gazillion occurrences! More function declarations
>will fit on a line! World peace will ensue and the moon will
>become habitable again!

Agreed, in my code I defined a macro theINTERP for that whole
aggravation which sort of hides the type in the macro but as we
only have 1 interp type...

>If people have visceral objections to typedef'ing pointers, I'm
>fine with dropping that part of the proposal. I'd just like to see

I've always been uncomfortable with that practice, its one part of
the whole Win32 world I hate. If you stick with the practice then
you either end up making a new typedef for every level of indirection
or you drop to using * (some typedef), etc. Now if it were C++ and we
were using a smart pointer class I don't mind the practice.

Anyway I'm one opinion in a haystack.

-Melvin Smith

IBM :: Atlanta Innovation Center
[EMAIL PROTECTED] :: 770-835-6984

Reply via email to