Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Zhiroc
Adept


Joined: 04 Feb 2005
Posts: 246

PostPosted: Sat Aug 02, 2008 8:27 pm   

[2.35] Parsing of local variables with no space afterwards
 
Consider the following example:
Code:
$name1 = "John"
$name2 = "Bill"
#SH {$name1/$name2}
#SH {$name1's}
//#SH {$name1/etc.}

The above works. But curiously, uncomment the last #SH, and you get a parse error. A little experimentation shows that you can do:
Code:
$name1/etc = "foo"
#SH {$name1/etc}

But in that case, "$name1/$name2" should have been looking for a "$name1/" variable. The docs don't specify the syntax of a local variable, but it would make sense to disallow most punctuation (other than "_")
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Sat Aug 02, 2008 10:31 pm   
 
As far as I can tell, the manual doesn't specify the syntax of specifying variables in other modules or packages...(!)
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Sun Aug 03, 2008 5:19 pm   
 
That error does seem a bit odd. However, note that this works:
#SH {$name1"/etc."}

Yes, it seems to me that local variable names should not be able to contain slashes or certain other punctuation.
Reply with quote
Zhiroc
Adept


Joined: 04 Feb 2005
Posts: 246

PostPosted: Wed Aug 13, 2008 3:58 am   
 
I think this behavior is a bug, so I'll bump it once, since it looks like it got buried :)
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Aug 13, 2008 4:53 pm   
 
I think it is just the / character that is causing the problem. It seems to be trying to parse the //module/class/var syntax for local variables, even though that doesn't really make any sense. I probably copied some code that was used for normal @var parsing and then didn't take out the handling of the / character properly.

Added to bug list.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Aug 13, 2008 10:33 pm   
 
I have removed the code that was handling the / character with a local variable reference. That seems to have fixed the problem and I haven't found any side effects.

When testing your procedure on the command line, I also ran across another bug. If you do this on the command line:
Code:
a="test";#show @a

then notice the it displays "test" *with* the quotes! Side effect of something I added a few versions ago for the smart command line. This was also causing the same problem with local variable assignment on the command line. Anyway, I have also fixed this problem now. So in 2.36, the code:
Code:
$name1 = "John"
$name2 = "Bill"
#SH {$name1/$name2}
#SH {$name1's}
#SH {$name1/etc.}

now properly shows:
Code:
Bill/John
Bill's
Bill/etc.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net