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
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Fri Dec 07, 2007 4:05 am   

[2.15] Dot notation of records is being ignored
 
From Zmud:

#additem defs.norm defense

Would add "defense" to the value string of the "norm" key in the record variable "defs".

In Cmud it adds "defense" as a string addition to "defs". Effectively Cmud is ignoring the record "." notation and doing this:

#additem defs defense

I read through the changes to Cmud, but I didn't see anything about this notation changing, so I'm assuming this is a bug.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Fri Dec 07, 2007 7:56 am   
 
I'm really torn as to whether this should be a bug or not. While the behavior is definitely different from that of zMUD, I'm not entirely sure that zMUD should have accepted such loose scripting. On the other hand CMUD interpreting the '.' as a space and changing the DB record to a stringlist can also have dire consequences.

Only Zugg can really say how easy/hard this will be to change.

If you need a work around you can do something like this:

Code:
#ADDKEY def s {norm=defense}
or
#VAR defs.norm defense


If it truly is a string list, then put the list in a local variable and use the #ADDKEY command to assign.


I wonder how other folks way in on this. Should the zMUD behavior be supported (which would mean this is broken) or should it be disallowed?
_________________
Asati di tempari!
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Fri Dec 07, 2007 8:56 am   
 
I believe that this worked in previous versions of CMUD, and should probably continue to do so. Some people get a lot of mileage out of it.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Fri Dec 07, 2007 11:41 am   
 
It didn't work in 2.14a either, but that was the only version I had readily on hand.
_________________
Asati di tempari!
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Fri Dec 07, 2007 3:32 pm   
 
Tech,

It's a matter both of conciseness and compatibility. I'm personally in favour of the shorter notation and as far as compatibility this code is used extensively in Larkin's Acropolis and so I'd prefer to not have to change it everywhere it was used.

By the way, I believe the below is the proper alternate:

Orig:
#additem defs.norm defense

Alternate:
#addkey defs norm %additem(%db(@defs,norm))

Edit: I'll add as well that it is non-functional as far as reading the variable goes as well. For example "#say @defs.norm" isn't displaying the value of the norm key as it should. I'm going to have a ton of stuff to change if this never gets fixed.
Reply with quote
Lina
Novice


Joined: 12 Oct 2006
Posts: 49

PostPosted: Fri Dec 07, 2007 4:04 pm   
 
Think I was told in earlier version of CMUD2 to use @{defs.norm} now and not just @defs.norm. Would that make a difference for you?
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Fri Dec 07, 2007 4:10 pm   
 
I tried using the syntax you noted above, but it didn't work. Did it work for you in previous versions of CMud?
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Fri Dec 07, 2007 4:52 pm   
 
Lina - that's true only in cases where the @ symbol is needed and when the variable name is some kind of complex combination of strings. Neither of those is true in this case.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Zugg
MASTER


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

PostPosted: Fri Dec 07, 2007 6:11 pm   
 
This kind of nested syntax is not going to be supported in this public version.

When the hash tables were added for speed improvement to string lists and database variables, it introduced a problem with nested lists/databases. When you use

#additem defs.norm defense

you are creating a string list within a database variable record. And CMUD cannot create a hash table for the string list in this case. In other words, CMUD can only create hash tables for string lists and database variables for the main variable setting. In the above example, @defs is the main variable. So CMUD can create a hash table for @defs. But it cannot create a hash table for @defs.norm because CMUD can only store string values within a hash table, and so @defs.norm needs to be a normal string value and not a string list.

In the future I will look into this syntax to see if I can still support it in the "slow" method that CMUD used to use for string lists and database variables.

You can get around this using the %additem as mentioned above since the %additem function can return a normal string value. But I wanted people to be aware of the limitations of this system so that you'll understand why you will not get any speed benefits when using nested lists/database variables. In fact, it will probably be a bit slower since CMUD will need to do a lot more conversions between hash tables and string values.

Anyway, this is on my list to look into in the future, but it's not going to change for this public release.
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Fri Dec 07, 2007 6:38 pm   
 
Thanks for the explanation Zugg. Your thoughtful and descriptive replies puts you a step above the rest.

Knowing now what you explained, I'd rather convert all my usages of this to an alternate method rather than suffer a speed penalty. I'd put speed of execution high on my list. I'd rather see this syntax removed from CMud than to be included with a speed penalty. A note in the upgrade guide and an extra item in the compatibility report would be sufficient.

By the way can anyone think of a quick way to locate these instances in my code? I could do this with a regular expression search, but nothing comes to mind with the standard search provided in the editor.
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Fri Dec 07, 2007 6:48 pm   
 
You could click onto the XML tab of a class, copy the XML into your favourite regex app, make the changes then copy it back. Would mean you could do every trigger in one go
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Fri Dec 07, 2007 7:05 pm   
 
I like that. Emacs should be able to make sort work of the changes. Is it just that easy to copy it back into that tab? It won't mess it up copying XML into the XML class tab will it?
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Fri Dec 07, 2007 7:38 pm   
 
I'm thinking XML export then, regex on the file will be the quickest overall way.

[Edit] Ninja strikes again.
_________________
Asati di tempari!
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Fri Dec 07, 2007 11:27 pm   
 
ReedN, I know that Larkin's Acropolis has a lot of usage of the string list inside of a database variable.

Here is something helpful for getting rid of a LOT Of this usage. These presents aren't in the help file yet.

Zugg wrote:
I have added the following functions to v2.06:

Code:
#ADDKEY dbvar Name Zugg
#ADDKEY dbvar Race Dwarf
#ADDKEY dbvar Level 10



%dbkeys(@dbvar)
Returns a string list of keys in the database variable. Example: "Name|Race|Level"
%dbvalues(@dbvar)
Returns a string list of values in the database variable. Example: "Zugg|Dwarf|10"
%isvalue(@dbvar,Value)
Returns the index of the key that contains the value. Returns zero (false) if not found. Example: %isvalue(@dbvar,"10") returns 3
%iskey(@dbvar,Key)
Fixed this existing function to return the proper index of the matching key (as versions prior to 2.00 did)
%item(@dbvar,n)
Improved this existing function to return the nth key of a database variable. Example: %item(@dbvar,3) returns "Level"

Note that in all cases, the value of the "nth" item of a database variable depends upon the internal hash order and has nothing to do with the order in which items were added, nor does it have anything to do with the sorted order of the record. So the index for %item really needs to come from either %iskey or %isvalue, and if the database variable is modified, these index values might change.

Anyway, that should take care of the other functions that Seb was looking for.


To do away with the heavy use of the keys string list you can use the %dbkeys function.

There are many uses I can think of for these new tidbits that can help reduce using string lists inside of database variable values...
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sat Dec 08, 2007 3:36 am   
 
You could also use Lua, which allows nesting tables Twisted Evil


defense = { norm           = {"def1", "def2"}
            something_else = {"def1", "def2"}
          }
print(defense.norm[1])
print(table.remove(defense.something_else,1))
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Dec 09, 2007 12:19 am   
 
I think I am fine with the dot notation not working with #ADDITEM and #DELITEM. I am however finding some oddities with the notation that affect the ability to use COM objects. I am not sure when they were introduced since I tend to avoid both the dot notation and COM like the plague.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Sun Dec 09, 2007 12:27 am   
 
Arminas wrote:
ReedN, I know that Larkin's Acropolis has a lot of usage of the string list inside of a database variable.
Here is something helpful for getting rid of a LOT Of this usage. These presents aren't in the help file yet.

I was thinking it would be hard to change it over but those new functions really make it a snap! Thanks for suggesting those.
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