'void' arguments (Yet Another Feature Proposal)

Risto Lankinen risto at tuura.UUCP
Tue Jan 22 22:41:38 AEST 1991


Hi!

Suppose there's function...

   SetThisMode( int iMode,int iValue1,int iValue2,int iValue3 );

also suppose the documentation says that 'when iMode==<xyz>, then none of
the iValue:s have any effect'.  In code you'd then write:

   SetThisMode( <xyz>,0,0,0 ); or SetThisMode( <xyz>,<your-age-in-days>,
      <temperature-in-Kelvins>,<number-of-emptied-Coke-cans-this-week> );

when you could be doing...

   SetThisMode( <xyz>,(int)any,(int)any,(int)any );

where the 'any' is my proposal for a keyword (as promised in the header).
It could be any other, too, for that matter - I actually tried some 'void'
derivatives, to check out whether there already were a legal way to do so.

Why?  Because I feel the code would be more readable with this arrangement,
and because the compiler will have some more freedom to optimize this kind
of function calls (a PUSH 0 would become PUSH <anyreg>, which is smaller
and maybe faster too, or a sequence of them would become SUB SP,<sizesum>
which definitely is more optimal in both size and speed).  I also think
that _pascal functions with variable arguments would become much easier to
implement (with the cost of added stack usage) by declaring arguments for
the 'worst case', and then using only those that are needed.

Terveisin: Risto Lankinen
-- 
Risto Lankinen / product specialist ***************************************
Nokia Data Systems, Technology Dept *  2                              2   *
THIS SPACE INTENTIONALLY LEFT BLANK * 2 -1 is PRIME!  Now working on 2 +1 *
replies: risto at yj.data.nokia.fi     ***************************************



More information about the Comp.lang.c mailing list