Page 1 of 1 1
Topic Options
#182418 - 2007-11-10 04:31 AM 4.60 bug: Function
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Teh FUNCTION doesn't seem to handle parameters withthe same name as the function correctly:
 Code:
$a=100

$b=a($a)
? 'Kix = '+@kix
? 'a = '+$a
? 'b = '+$b

function a($a)
  $a=100
endfunction

returns
 Code:
Kix = 4.60
a = 100
b =


However,
 Code:
$a=100

$b=a($a)
? 'Kix = '+@kix
? 'a = '+$a
? 'b = '+$b

function a($b)
  $a=100
endfunction

correctly returns
 Code:
Kix = 4.60
a = 100
b = 100
_________________________
There are two types of vessels, submarines and targets.

Top
#182427 - 2007-11-10 09:44 AM Re: 4.60 bug: Function [Re: Sealeopard]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I don't think that this is a bug. Wouldn't you expect this to happen? I would \:\)

You are creating a local variable with the same name as the function return variable, and so obscuring the special variable that you use to return values.

It's similar to having a global and local variable with the same name - you cannot access or change the global variable while the local variable is present.

This behaviour is the same in 4.53

Top
#182482 - 2007-11-12 10:55 AM Re: 4.60 bug: Function [Re: Richard H.]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I too think this is expected.
_________________________
!

download KiXnet

Top
#182522 - 2007-11-12 08:09 PM Re: 4.60 bug: Function [Re: Lonkero]
paperinik Offline
Fresh Scripter

Registered: 2007-11-04
Posts: 23
Loc: Germany
After some tests,
I think it's definitely NOT a bug.

Top
Page 1 of 1 1


Moderator:  ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 666 anonymous users online.
Newest Members
rrosell, PatrickPinto, Raoul, Timothy, Jojo67
17877 Registered Users

Generated in 0.051 seconds in which 0.023 seconds were spent on a total of 13 queries. Zlib compression enabled.