Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Use of 'our' considered harmful

by tantarbobus (Hermit)
on Sep 24, 2004 at 10:50 UTC ( #393443=note: print w/replies, xml ) Need Help??


in reply to Re: Use of 'our' considered harmful
in thread Use of 'our' considered harmful

I actually like the K&R prototypes beter than the ansi:
int foo(this, that, these) char *this; char *that; char *these; { } /* Is much nicer than: */ int foo(char this, char that, char those) { }

Replies are listed 'Best First'.
Re^3: Use of 'our' considered harmful
by ambrus (Abbot) on Sep 24, 2004 at 11:01 UTC

    The point in ANSI prototypes is that when you use them, any call to the function will actually convert the parameters to whatever type the prototye says.

    More clearly, the K&R style declaration of arguments (which is not a prototype btw) say only what the function pops off the stack, but not what the caller pushes to the stack. If, however, a function has an ANSI C prototype (and it's included in wherever you call the function from), the C compiler will automatically convert parameters to whatever the prototye says, and will warn you if you call the function with an incompatible number or type of parameters.

      I meant declaration ;). But My point was more about the syntax. I like the former better because, for me, it is just easier to scan.
Re^3: Use of 'our' considered harmful
by mpeppler (Vicar) on Sep 24, 2004 at 11:19 UTC
    Nothing to stop you writing
    int foo ( char *this, char *that, char *these ) { ... }
    FWIW... :-)

    Michael

Re^3: Use of 'our' considered harmful
by Jenda (Abbot) on Sep 24, 2004 at 13:29 UTC

    In both cases the type (and most of the modifiers and other cruft) is on the wrong side of the variable. Does anyone think "and now I'm going to need an int, let's call it counter"? I think not. Normal people say to themselves "and now I'm going to need a counter, an int will be enough".

    Not speaking about the mess with pointers to functions and functions returning pointers etc. int *foo() vs. int (*)foo() anyone?

    Jenda
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
       -- Rick Osborne

      I'm not normal. :-) Because of this, I always make mistakes in SQL when creating tables.

        Too much C over a too long period? ;-)

        Jenda
        Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
           -- Rick Osborne

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://393443]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2019-10-21 06:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?