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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Fri Oct 23, 2009 5:23 am   

[Feature request]Expansion of the &varname syntax
 
Inspired by this thread in the General forum: http://forums.zuggsoft.com/forums/viewtopic.php?p=151353#151353

&[%w%s]varname

Assuming it's not already possible (and is still valid under regex), is there any chance of one day getting &varname expanded to include the range matching?

...yes, I know, in your copious amounts of spare time. Mr. Green
_________________
EDIT: I didn't like my old signature
Reply with quote
Zugg
MASTER


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

PostPosted: Fri Oct 23, 2009 3:39 pm   
 
No, I really don't want to do this. This makes the trigger parser much more complicated. I'd rather that people stick with the traditional method of using () in the pattern to capture the substring, and then assign it using: varname=%1 in the script. That actually makes your script a bit faster since the variable assignment reference gets compiled, whereas with the embedded variable in the trigger pattern it doesn't.

In other words, when you do this:

#TRIGGER {whatever (%w) test} {varname = %1}

the lookup of the @varname reference is done *once* at compile time, making the trigger execute faster. Compared to this:

#TRIGGER {whatever &%wvarname test} {#noop}

where the lookup of the @varname reference is done at runtime each time the trigger fires.

Also, you can already use the regular expression syntax to accomplish what you want:

#REGEX {whatever (?varname:[\w\s])} {#noop}

I think that is the regex syntax for assigning a subpattern to a varname, but someone can correct me if I've got it wrong.

Anyway...bottom line is that I'd rather see people encouraged to use standard pattern syntax and then do their variable assignments in the script. It's faster and easier to support and debug too.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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