Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Short-Circuiting with Logical Operators
Message
De
28/10/2014 19:15:04
 
 
À
28/10/2014 11:37:25
Lutz Scheffler (En ligne)
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows Server 2003
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01609995
Message ID:
01610061
Vues:
38
>If it is important that a function returns or changes something different then its value then it's a non good design.
>IOW. If a function just does what is is made for (return a value depending on it's input) no harm can be done by shortcutting.

One example of a common function that has a "side effect" (as part of its implementation) is the pseudo-random number generator function. Each call to the function will modify the seed value. Advantage to this implementation is that you've got repeatability (which of course sounds funny as it seemingly contradicts the usage as (pseudo-)random number generator) for debugging and testing -- you simply start with a specific seed value, then you're guaranteed to have the same sequence of (pseudo-)random numbers being generated. Typical way to "randomize" the values is by using some frequently-changing value as the seed (e.g. the system time).
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform