Laurent Guerby a �crit dans le message : 863dtqfo26.fsf@ppp-173-146.villette.club-internet.fr... > [I originally posted this in the 11.6 thread, but got no answer] > > If we have the following function: > > function Cond_T (C : in Boolean; If_True, If_False : in T) return T; > pragma Inline (Cond_T); > > function Cond_T (C : in Boolean; If_True, If_False : in T) return T is > begin > if C then > return If_True; > else > return If_False; > end if; > end Cond_T; > > And the following expression: > > C : constant Boolean := Some_Run_Time_Value_That_The_Compiler_Cannot_Guess; > > X : constant T := Cont_T (C, If_True => Super_Expensive_Function_Call_1, > If_False => Super_Expensive_Function_Call_2); > > The question is: is a smart Ada 95 compiler allowed to generate code > that looks like this: > > if C then > X := Super_Expensive_Function_Call_1; > else > X := Super_Expensive_Function_Call_2; > end if; > > that is to say, be lazy about its argument, and so might > save execution time. > The simplest solution in this case would be to pass pointers to the Super_Expensive_Function_Calls; This way, only the *pointers* are evaluated at the call, the functions are actually called only as necessary... -- --------------------------------------------------------- J-P. Rosen (Rosen.Adalog@wanadoo.fr) Visit Adalog's web site at http://pro.wanadoo.fr/adalog