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
phranq
Beginner


Joined: 11 Jul 2006
Posts: 13

PostPosted: Sat Aug 18, 2007 6:24 am   

@%1 ... can't do it anymore?
 
I need to send something in an alias like this.


#alias (abc) {~abc @%1}

@123=xyz
abc 123

abc xyz


right now it will send

abc @123


How do I get it to expand using the @%1 method?
Reply with quote
Zugg
MASTER


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

PostPosted: Sat Aug 18, 2007 6:31 am   
 
The correct syntax is:

#alias (abc) {~abc @{%1}}

Indirect variable references always looks like @{stringvalue} where "stringvalue" is the string that represents the name of the variable you wish to expand.
Reply with quote
phranq
Beginner


Joined: 11 Jul 2006
Posts: 13

PostPosted: Sat Aug 18, 2007 6:42 am   
 
I could've sworn I tried that, but it works!


I think I tried every variation with brackets and parentheses, but missed that one somehow... thanks.
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Sat Aug 18, 2007 12:50 pm   
 
I had trouble with a variation on this the other day, too.

Code:
#for (health|mana) {#show @{concoctions.%i}}
#for (health|mana) {#show @concoctions.%i}


Second one works, first one doesn't--this seems wrong?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sat Aug 18, 2007 12:52 pm   
 
That is rather strange, and it does seem wrong. I remember people mentioning that @{dbvar.key} worked before with dynamically-named keys :S
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Zhiroc
Adept


Joined: 04 Feb 2005
Posts: 246

PostPosted: Sat Aug 18, 2007 5:02 pm   
 
Something else I noticed: @var compiles into a VARREF, and @{var} into a USERFUNC. Any speed difference between the two?

Sometimes you have to use @{var} if referenced in the middle of text, as in "@{var}East". The parser could perhaps tell whether "var" is a string literal or not, and compile them the same way.
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Sat Aug 18, 2007 5:16 pm   
 
Good call. As a temporary workaround, @var~text works (compiles as varref) (for some uses at least?, I don't have a lot of test cases).
Reply with quote
Zugg
MASTER


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

PostPosted: Sat Aug 18, 2007 5:24 pm   
 
Quote:
@var compiles into a VARREF, and @{var} into a USERFUNC. Any speed difference between the two?

Yes! A VARREF is a direct compiled reference to a variables location in the database. A USERFUNC is an indirect variable reference, and it needs to lookup the variable by name at run-time. Even though the lookup uses a hash table, indirect variable references will always be a bit slower than direct references.

I'll look into the bug with @{dbvar.key} and see what's happening there.

Quote:
"@{var}East". The parser could perhaps tell whether "var" is a string literal or not, and compile them the same way.


I'll see if I can add that optimization to the compiler.
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