I don't suffer from insanity, I enjoy every minute of it !!!
Verwijderd
het gaat dus hier over:
(voor degene die geen zin hebbe de link te openen)Call by name
A call by name is functionally much like a call by reference, but is slightly different in spirit. Instead of passing the address of a variable as an argument, a language that implements call-by-name (i.e., Algol-60) passes a thunk--a pair of functions that provide read and write access to the variable. In the case of simple variables (i.e., not arrays), call-by-name yields the same results as call-by-reference. When an argument to a function or procedure is an array element, however, its index expression is re-evaluated in the caller's scope every time the parameter is used within the function or procedure. Indeed, the swap example below is perhaps the canonical example of the perils of call-by-name. In fact, with call-by-name it is impossible to implement a "foolproof" version of such a swap function.
The basic difficulty with call-by-name results from the side effects that assignment via thunk can cause. For example, if an array element is passed as an argument, the precise element of the array being referred to can depend on the state; hence, if the state changes, so does the element being referred to. In the example, both i and a[i] are passed as arguments to the same function; then, when i changes, a[i] refers to a different element of the array from that which was (probably) intended.
Het idee is dat 'y=t' betekent @global_a[@global_x] = t, waarbij de @ staat voor evaluatie op dat punt. De print in swap() laat zien dat @global_x==2, dus het tweede element wordt veranderd.
Man hopes. Genius creates. Ralph Waldo Emerson
Never worry about theory as long as the machinery does what it's supposed to do. R. A. Heinlein
Zoals ik het begrijp heb je call by name en call bij value, bij call by name pakt ie de variabele en gaat daar verder mee werken, bij call by value pakt ie de waarde van de variabele en gaat daar verder mee werken
Bikkelen gebeurt pas na 2:00
ik denk dat je het verwardt met call by reference, waarbij het adres van de variabele wordt doorgegeven ipv de waarde van de variabeleOp donderdag 30 mei 2002 16:50 schreef Sjnirk het volgende:
Zoals ik het begrijp heb je call by name en call bij value, bij call by name pakt ie de variabele en gaat daar verder mee werken, bij call by value pakt ie de waarde van de variabele en gaat daar verder mee werken
Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.