Re: calling different functions but using one name; or assigning a function t...

From: VBDis (vbdis_at_aol.com)
Date: 10/07/04


Date: 07 Oct 2004 10:59:20 GMT

Im Artikel <2sis07F1ksgnoU1@uni-berlin.de>, "Allan M. Due" <me@privacy.net>
schreibt:

>What I would like is to have
>
>if (condition1) algo := old_algo else algo:=new_algo;

Place that decision into the function itself, and add your new code there.

For a static replacement (at compile time) you can use {$IF ...}, or a const
for condition1 so that the compiler can eliminate the dead code in the never
choosen branch.

The other solutions with procedure pointers and overloading have already been
mentioned otherwhere. Overloading also makes a static selection, at compile
time, whereas procedure or method pointers can be changed at runtime.

DoDi



Relevant Pages

  • Re: Python and Flaming Thunder
    ... the compiler optimizes it away, ... I think overloading your catch error types to include objects ... assignment could throw an error) makes things confusing. ...
    (comp.lang.python)
  • Re: Declaration design preference: type or name first
    ... the compiler defaults to integer. ... Haskell uses type classes to handle overloading. ... that is an instance of the Num type class and returns a value of the ... This would make it illegal to apply f to, say, a string, ...
    (comp.lang.misc)
  • Re: why cant functions return arrays
    ... at initialization. ... I think you don't understand your own compiler. ... but you have not specified how overloading works with arrays unless I ... Pointer + integer ...
    (comp.compilers.lcc)
  • Re: Operator overloading in C
    ... Operator overloading integrates cleanly with C. ... and not be part of the standard. ... Basically the algorithm for modifying the compiler runs like this: ... and the committee tands to prefer proposals ...
    (comp.std.c)
  • Re: Operator overloading in C
    ... Modify the lexer to recognize "operator" at the global ... the compiler copies foo into that address. ... I'd suggest leaving arrays out of this scheme, ... that would actually be needed for overloading would be structure ...
    (comp.std.c)