Page 1 of 1 1
Topic Options
#199573 - 2010-08-15 06:22 AM What the [Censored]?
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Can someone explain this...

 Code:
@kix
$i=0
? ("test"<>$i)
? ($i<>"test")


The first test line returns 1
The second test line returns 0

Why? Shouldn't they return the same value?

Top
#199574 - 2010-08-15 02:34 PM Re: What the [Censored]? [Re: Allen]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
I'm guessing this is KiX's auto intepreter stuff.
Assuming correctly $i is an Integer so the second test correctly displays 0. The first test should not pass at all.
I wish KiX would error out when comparing different types of variables. (PowerShell does)

Top
#199575 - 2010-08-15 02:46 PM Re: What the [Censored]? [Re: Arend_]
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
This is actually one of the advantages of KiXtart. Teaches you to correctly declare/use your variables. This variable behavior is demonstrated in the "Expressions" section of the KiXtart Manual.
_________________________
There are two types of vessels, submarines and targets.

Top
#199576 - 2010-08-15 03:14 PM Re: What the [Censored]? [Re: Sealeopard]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
I guess I should have put the comparison script in too...

 Code:
@kix
$i=1
? ("test"<>$i)
? ($i<>"test")


Both test lines return 1 here...

Top
#199577 - 2010-08-15 04:17 PM Re: What the [Censored]? [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
anyways, like said, it's behaving correctly.
"test"<>$i converts $i to string.
"test" is different than "0" or "" or "1"

$i<>"test" forces conversion from string to integer. there is0 no numeral part in "test" so the comparison in your examples is:
$i<>0
_________________________
!

download KiXnet

Top
#199598 - 2010-08-16 03:09 PM Re: What the [Censored]? [Re: Lonkero]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Remember that all KiXtart types are VARIANT, as documented in the manual.

This means that it is behaving correctly when promoting variables to different sub-types, and IIRC there are similar processes in other languages which support variants.

Strongly typed variable support has its place, but it would probably hinder KiXtart more than provide anything useful. If we had direct access to things like DLL function calls it would be more important.

This auto-conversion of variant types is probably the reason many of us still use short form Hungarian notation for variable names when it has largely fallen out of favour.

Top
#199601 - 2010-08-16 03:46 PM Re: What the [Censored]? [Re: Richard H.]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Hmm... and all this time I thought I was using Hunarian Notation as a tribute to my Hugarian ancestry! \:D

G-
_________________________
Actually I am a Rocket Scientist! \:D

Top
#199605 - 2010-08-16 05:37 PM Re: What the [Censored]? [Re: Glenn Barnas]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
wtf? hunarian? hugarian? lol!
_________________________
!

download KiXnet

Top
#199606 - 2010-08-16 06:30 PM Re: What the [Censored]? [Re: Lonkero]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
I wondered if anyone would catch that.. Figures it would be Lonk..

I still think it's funnier my way. ;\)

G-
_________________________
Actually I am a Rocket Scientist! \:D

Top
#199607 - 2010-08-16 06:34 PM Re: What the [Censored]? [Re: Glenn Barnas]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yea \:\)
_________________________
!

download KiXnet

Top
#199614 - 2010-08-17 01:04 PM Re: What the [Censored]? [Re: Lonkero]
BradV Online   content
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
I saw it, but didn't want to make any smart remarks. Being from New Jersey is bad enough. \:\)
Top
#199616 - 2010-08-17 03:28 PM Re: What the [Censored]? [Re: BradV]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
New Jersey? So, Newark and New York isn't your fault?
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#199619 - 2010-08-17 09:13 PM Re: What the [Censored]? [Re: Björn]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Ugh - I'm smack-dab between the two - NYC is 10 miles due East, while Newark is 10 miles due South. It could be worse, but not by much.. ;\)

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
Page 1 of 1 1


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

Who's Online
1 registered (Allen) and 382 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

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

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org