#110868 - 2004-01-09 09:32 AM
Re: 4.5 alpha
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
rich, nope...
have to disagree on that one.
example tokenization of:
$foo="bar"
$bar="test"
$=Execute('"The value of $$$$'+$foo+' is "+$$'+$foo+' ?')
should lead to something like:
$1="bar"
$2="test"
$3=Execute('"The value of $$$$'+$1+' is "+$$'+$1+' ?')
Lonk, look again at the example and you will see why tokenising variables names is a problem.
I'll bet you didn't try to execute your sample tokenised code, did you?
The tokenised code returns:
Code:
The value of $bar is
When of course the script should be returning:
Code:
The value of $bar is test
|
Top
|
|
|
|
#110869 - 2004-01-09 09:54 AM
Re: 4.5 alpha
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
what comes to called scripts, if they are to share same namespace, they will have same names.
No, when it comes to tokenised names that is not correct.
Ok, consider two very simple scripts:
S1.KIX Code:
Global $sApple, $sOrange
$sApple="Apple" $sOrange="Orange"
Call S2.kix
S2.KIX Code:
Global $sPear, $sOrange, $sApple
"Value of $$sPear is '"+$sPear+"'" ? "Value of $$sOrange is '"+$sOrange+"'" ? "Value of $$sApple is '"+$sApple+"'" ?
Run these and you get what you'd expect:
Quote:
Value of $sPear is '' Value of $sOrange is 'Orange' Value of $sApple is 'Apple'
Now, tokenise the variables: S1.KIX Code:
Global $1, $2
$1="Apple" $2="Orange"
Call S2.kix
S2.KIX Code:
Global $1, $2, $3
"Value of $$sPear is '"+$1+"'" ? "Value of $$sOrange is '"+$2+"'" ? "Value of $$sApple is '"+$3+"'" ?
Now when you run the scripts, you will get an incorrect result:
Quote:
Value of $sPear is 'Apple' Value of $sOrange is 'Orange' Value of $sApple is ''
These are contrived examples, but you can easily see why variable names must be preserved in tokenised code.
|
Top
|
|
|
|
#110871 - 2004-01-09 01:40 PM
Re: 4.5 alpha
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
think I need to give example, of both ways in my head. using your initial scripts. btw, isn't there double declaration in your script? so much time when I last coded... can't remember how these go
now, if tokenizing and having call and ruud makes call work as include, results is like: Code:
Global $1, $2 $1="Apple" $2="Orange" Global $3, $2, $1 "Value of $$sPear is '"+$3+"'" ? "Value of $$sOrange is '"+$2+"'" ? "Value of $$sApple is '"+$1+"'" ?
when not using include, the result might be: S1.kx Code:
] Global $1, $2 $1="Apple" $2="Orange" call "s2.kx"
s2.kx Code:
Global $3, $2, $1 "Value of $$sPear is '"+$3+"'" ? "Value of $$sOrange is '"+$2+"'" ? "Value of $$sApple is '"+$1+"'" ?
anyway, looking at your code's var declarations, it seems that it shouldn't work anyways...
_________________________
!download KiXnet
|
Top
|
|
|
|
#110872 - 2004-01-09 01:54 PM
Re: 4.5 alpha
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
or they are tokenized too
The code has to be monolithic - individually tokenised scripts will have the same problem.
If all subscripts are included in-line before tokenisation and you never need to expand variable names (variable-variables, indirection, Execute statements) then you could probably tokenise variable names, although I might have missed something.
I knew there was something else nagging me - the following will not work with tokenised variable names: Code:
kix32.exe $sMyDomain="ACME" tokenised.kx
IMO the loss of these and other features far outweighs the very minor gains that tokenising variable names would give.
Perhaps tokenisation of variables names could be a tokeniser option for hardcore golfers
Reducing variable names to single character can be handled by a pre-parser, if that is all that is required.
|
Top
|
|
|
|
#110876 - 2004-01-09 04:05 PM
Re: 4.5 alpha
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
OK, will admit it was a bit of a brain fart. Did not think it through. Still, have to wonder (BF Alert) if Execute() could be pre-parsed for var names.
The quick answer is "no".
The long answer is that Execute() statements have to be parsed at run-time. You cannot substantiate a variable until it has a value, and it does not have a value unless the code is executing.
In the case of the example I gave the value of the (indirectly referenced) variable is constant as it is a very simple example. In a more complex example the variable name may be constantly changing.
|
Top
|
|
|
|
#110878 - 2004-03-19 08:45 AM
Re: 4.5 alpha
|
Balu
Lurker
Registered: 2004-03-19
Posts: 1
|
First sorry for deviating from the main subject.
I am a user of the KiXtart version 4.22, I want to test and use KiXtart that supports the tokenizing functionality. Can anyone point me to the place where I can get the build that supports this feature?
Or do I have to mail anybody in obtaining it?
Thanks for your help, Bala
|
Top
|
|
|
|
#110882 - 2004-04-01 03:35 PM
Re: 4.5 alpha
|
Jochen
KiX Supporter
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
Top
|
|
|
|
#110883 - 2004-04-01 04:29 PM
Re: 4.5 alpha
|
Ruud van Velsen
Developer
Registered: 1999-05-06
Posts: 391
Loc: Amsterdam, The Netherlands
|
I'm sure you can guess what the next version will be called....
|
Top
|
|
|
|
Moderator: ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 466 anonymous users online.
|
|
|