Ver Mensaje Individual
  #2  
Antiguo 17-08-2007
Avatar de jhonny
jhonny jhonny is offline
Jhonny Suárez
 
Registrado: may 2003
Ubicación: Colombia
Posts: 7.058
Reputación: 30
jhonny Va camino a la famajhonny Va camino a la fama
Cita:
Empezado por senda Ver Mensaje
Primero se ejecuta A, y luego (esto es lo que quiero saber) si A es falso ¿se ejecuta B o se pasa directamente a D?
Hay una directiva llamada $B, si $B es $B-, eso significara que esto se analizara de la manera "perezosa", osea que tomando tu ejemplo, si A no cumple la condición, pasara a ejecutar D y no tomara en cuenta a B. Si $B es igual a $B+ entonces hara lo contrario.

Nota: $B por defecto es negativo.

Cita:
Empezado por Ayuda de Delphi
Boolean short-circuit evaluation

Type Switch
Syntax {$B+} or {$B-}
{$BOOLEVAL ON} or {$BOOLEVAL OFF}
Default {$B-}
{$BOOLEVAL OFF}
Scope Local
Remarks

The $B directive switches between the two different models of code generation for the and and or Boolean operators.

In the {$B+} state, the compiler generates code for complete Boolean expression evaluation. This means that every operand of a Boolean expression built from the and and or operators is guaranteed to be evaluated, even when the result of the entire expression is already known.
In the {$B-} state, the compiler generates code for short-circuit Boolean expression evaluation, which means that evaluation stops as soon as the result of the entire expression becomes evident in left to right order of evaluation.

For further details, see the section "Boolean operators" in the Object Pascal Language Guide.
__________________
Lecciones de mi Madre. Tema: modificación del comportamiento, "Pará de actuar como tu padre!"

http://www.purodelphi.com/
http://www.nosolodelphi.com/

Última edición por jhonny fecha: 17-08-2007 a las 20:27:42.
Responder Con Cita