Re: possible useful macros...

Discussion in 'C Programming' started by John Gordon, May 23, 2012.

  1. John Gordon

    John Gordon Guest

    In <4fbd3048$0$1375$> "io_x" <> writes:

    > what about these macro?


    > #define MM malloc
    > #define FF free
    > #define ooo cout


    How are these useful?

    --
    John Gordon A is for Amy, who fell down the stairs
    B is for Basil, assaulted by bears
    -- Edward Gorey, "The Gashlycrumb Tinies"
     
    John Gordon, May 23, 2012
    #1
    1. Advertising

  2. John Gordon

    Eric Sosman Guest

    On 5/23/2012 3:56 PM, John Gordon wrote:
    > In<4fbd3048$0$1375$> "io_x"<> writes:
    >
    >> what about these macro?

    >
    >> #define MM malloc
    >> #define FF free
    >> #define ooo cout

    >
    > How are these useful?


    They're too verbose to be useful.

    For example, the identifiers `malloc' and `free' are nearly
    always followed by the token `(', and malloc is nearly always
    preceded by `='. There's thus an obvious improvement on the
    first two macros given above:

    #define M =malloc(
    #define F free(

    In the same vein, observe that the argument lists are quite often
    followed by semicolons, so a few more definitions become obvious:

    #define Z );
    #define S sizeof

    With these conveniences at hand, we can now write code like

    struct f*p M S*p Z
    // ... use the struct ...
    F p Z

    .... with the accompanying gains in productivity. The gains are
    even more striking in light of the fact that very many statements
    end with a function call, so the Z macro has wider applicability:

    P "hello, world!\n" Z
    E EXIT_FAILURE Z
    L jb,42 Z

    .... and so on. With fifty-two one-letter macro identifiers at
    our beck and call, we can look forward to denser code and faster
    compilations, since shorter source files can be read more quickly.

    The `ooo' macro, though, is silly. There are 52 one-letter
    macro names, and 52*(52+1+10)-(26+10) = 3240 two-character names
    (we must avoid infringing on 7.31.3's reserved names). With 3292
    short names available, there is no reason to waste typing time by
    resorting to three-letter identifiers. That's just foolish!

    --
    Eric Sosman
    d
     
    Eric Sosman, May 23, 2012
    #2
    1. Advertising

  3. John Gordon

    Guest

    On Wednesday, May 23, 2012 8:56:06 PM UTC+1, John Gordon wrote:
    > In <4fbd3048$0$1375$> "io_x" <> writes:
    >
    > > what about these macro?

    >
    > > #define MM malloc
    > > #define FF free
    > > #define ooo cout

    >
    > How are these useful?


    this is io_x. he keeps posting stuff like this.
     
    , May 24, 2012
    #3
  4. John Gordon

    Phil Carmody Guest

    John Gordon <> writes:
    > In <4fbd3048$0$1375$> "io_x" <> writes:
    >
    > > what about these macro?

    >
    > > #define MM malloc
    > > #define FF free
    > > #define ooo cout

    >
    > How are these useful?


    For trolling fools into responding, they're almost insurpassable
    in usefulness.

    Learn how to use a killfile. Most sane people don't want to see io_x's
    crap, and that includes when it's quoted in naive responses to it.

    Phil
    --
    > I'd argue that there is much evidence for the existence of a God.

    Pics or it didn't happen.
    -- Tom (/. uid 822)
     
    Phil Carmody, Jun 11, 2012
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Pfaff

    Re: possible useful macros...

    Ben Pfaff, May 23, 2012, in forum: C Programming
    Replies:
    0
    Views:
    303
    Ben Pfaff
    May 23, 2012
  2. Kaz Kylheku

    Re: possible useful macros...

    Kaz Kylheku, May 23, 2012, in forum: C Programming
    Replies:
    0
    Views:
    242
    Kaz Kylheku
    May 23, 2012
  3. Lanarcam

    Re: possible useful macros...

    Lanarcam, May 23, 2012, in forum: C Programming
    Replies:
    1
    Views:
    232
    Bartc
    May 23, 2012
  4. Ike Naar

    Re: possible useful macros...

    Ike Naar, May 23, 2012, in forum: C Programming
    Replies:
    0
    Views:
    227
    Ike Naar
    May 23, 2012
  5. Re: possible useful macros...

    , May 24, 2012, in forum: C Programming
    Replies:
    11
    Views:
    433
Loading...

Share This Page