 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Fri Aug 03, 2007 11:00 am
[1.34] Spaces munched by %eval |
Not sure if this has been reported before or not, but %eval eats spaces in strings:
#say %eval("this is a test")
Wouldn't normally be that big an issue except, as Tech is doing in this thread, when you want to access a dynamically-named variable:
#say %eval(%concat("@//",$name,"/test"))
Will eat any spaces in the variable's value. |
|
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Aug 06, 2007 5:52 pm |
When you pass a string value to a function, the original quotes around the value are not passed. For example, when you do:
#SAY "this is a test"
the quotes don't appear, right? So when you use #say %eval("this is a test"), you are passing a single string argument to %eval with the value "this is a test" WITHOUT the quotes. When %eval gets this text, it doesn't know what to do with it. It isn't an expression to evaluate (like 1+2) it's just a bunch of text words.
Now, I can understand the problem and try to fix it. It's related to the fact that for normal text commands, the space is the delimiter between arguments. For example, when you call an alias with arguments:
alias 1 2 3
you get 3 arguments with the values "1", "2", and "3" with no spaces. So spaces get stripped between arguments like this, and I think that is what is happening to the "this is a test" text.
In the case of
#say %eval(%concat("@//",$name,"/test"))
remember that the CMUD compiler is evaluating the argument to %eval as a single string argument. To simplify the example, just take a look at this:
a="this is a test"
#say %eval("@a")
This shows the problem with spaces being stripped directly. So yes, this is definitely some kind of bug. It looks like it might be recursively evaluating the expression so that instead of just evaluating @a, it also then evaluates the "this is a test" result, which then strips the spaces.
In any case, I have added this to the bug list to see what I can do. It certainly isn't what any user would expect to be happening. |
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Mon Aug 06, 2007 10:58 pm |
You're right - but with strings being that strict, how would someone go about accessing a variable with a dynamic name or path? That's the issue here more than %eval itself.
|
|
|
|
 |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|