On eating a small amount of crow

S

spinoza1111

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top