On eating a small amount of crow

Discussion in 'C Programming' started by spinoza1111, Nov 16, 2009.

  1. spinoza1111

    spinoza1111 Guest

    Last year I said that Kernighan was wrong to approve of Pike's use of
    in situ modification of value parameters in C, and was reminded, or
    told if you please, that "value parameters on the stack may be
    modified without modifying the value in the caller, and this is a Good
    Thing to Do for it saves memory".

    I agreed with the left half of the above and but demur from the right
    half for the most part except in the following C Sharp extempore-
    untested code, which is the guts of a routine to randomly generate
    Polish strings:

    return randomPolishExpression_
    (objRandomNumberGenerator, ++intLevel) + " " +
    randomPolishExpression_
    (objRandomNumberGenerator, intLevel) + " " +
    randomPolishExpression__randomOp_());

    intLevel is a value parameter which is passed to control the depth of
    the random Polish expression. Note that the pre-increment increments
    it in place, in situ if you please, on the stack, and thus both times
    it is passed I predict now (not having tested the code) it will be
    passed, correctly, as the next level.

    Note also that I trust to the strict left to right rule of C Sharp and
    not to the foul lawlessness of C, where logical ops are left to right
    but subroutine parameter can be in a y orders because foul Trogdolytes
    in the dark ages of programming wanted to generate code in one pass to
    push operands on the stack, reversing their natural order, like the
    trolls they were.

    It turns out to be elegant to modify intLevel. Although my first
    machines were low memory, I programmed in assembler thus never thought
    it fit to use value parameters as work areas.
    spinoza1111, Nov 16, 2009
    #1
    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. Replies:
    2
    Views:
    8,710
  2. Old Wolf

    Pointer to small amount of storage

    Old Wolf, Feb 22, 2008, in forum: C Programming
    Replies:
    28
    Views:
    727
    Keith Thompson
    Mar 10, 2008
  3. Peter Michael

    "Perlish Patterns" by Phil Crow

    Peter Michael, Aug 24, 2004, in forum: Perl Misc
    Replies:
    2
    Views:
    130
    Rocco Caputo
    Aug 25, 2004
  4. PerlFAQ Server
    Replies:
    0
    Views:
    113
    PerlFAQ Server
    Feb 1, 2011
  5. PerlFAQ Server
    Replies:
    0
    Views:
    105
    PerlFAQ Server
    Mar 31, 2011
Loading...

Share This Page