Changes between Initial Version and Version 1 of Ticket #2713
- Timestamp:
- 05/18/14 18:15:49 (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #2713 – Description
initial v1 1 In the following script, the presence of {{{ByRef}}} causes {{{$old}}} to be a reference, not a copy. 1 In the following script, the presence of {{{ByRef}}} causes {{{$b}}} to be a reference, not a copy. 2 2 3 {{{ 3 #include "car.au3" 4 Local $a[2] = [1, 2] 4 5 5 $car = Car () ; speed: 50 6 test($a[0]) 6 7 7 Func getAcceleratedCar (ByRef $car_speed) 8 Local $old = $car 9 $car_speed *= 2 10 Local $new = $car 8 Func test(ByRef $foo) 9 Local $b = $a 10 $foo += 1 11 11 12 Car_printSpeed ($car, "car") ; speed: 100 13 Car_printSpeed ($old, "old") ; speed: 100, expected 50 14 Car_printSpeed ($new, "new") ; speed: 100 15 16 $car = $old 17 return $new 18 EndFunc 19 20 getAcceleratedCar ($car [$Car_Speed]) 12 ConsoleWrite($a[0] & @LF) 13 ConsoleWrite($b[0] & @LF) 14 EndFunc ;==>test 21 15 }}} 22 23 car.au3:24 {{{25 ; class Car26 Func Car ($speed = 50)27 Local $__instance [$__Car__ObjectSize] = [$__Car__VTable]28 $__instance [$Car_Speed] = $speed29 return $__instance30 EndFunc31 Func __Car__printSpeed__Impl (ByRef $__instance, $name)32 ConsoleWrite ("speed of " & $name & ": " & $__instance [$Car_Speed] & @CRLF)33 EndFunc34 Func Car_printSpeed (ByRef $__instance, $__arg1)35 Local $function = ($__instance [$__Car__VTableIndex]) [$__Car__printSpeed__Index]36 Return $function ($__instance, $__arg1)37 EndFunc38 Const $__Car__VTableIndex = 039 Const $__Car__VTable = [__Car__printSpeed__Impl]40 Const $__Car__printSpeed__Index = 041 Const $__Car__ObjectSize = 242 Const $Car_Speed = 143 ; end class Car44 }}}