Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Short-Circuiting with Logical Operators
Message
From
28/10/2014 19:15:04
 
 
To
28/10/2014 11:37:25
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows Server 2003
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01609995
Message ID:
01610061
Views:
39
>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).
Previous
Reply
Map
View

Click here to load this message in the networking platform