TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

tintin 1.99.7: List-like vars are automatically reordered

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
louipc



Joined: 16 Jul 2006
Posts: 65

PostPosted: Mon Aug 31, 2009 8:38 pm    Post subject: tintin 1.99.7: List-like vars are automatically reordered Reply with quote

tintin 1.99.7: List-like vars are automatically reordered

#var is doing too much here.
I think this should only occur if using:
Code:
#list foo insert {index} {value}


Code:
#var foo {{a1}{a2}{a3}{a4}{a5}{a6}{a7}{a8}{a9}{a10}{a11}{a12}{a13}{a14}}
#OK. VARIABLE {foo} HAS BEEN SET TO {{a1}{a2}{a3}{a4}{a5}{a6}{a7}{a8}{a9}{a10}{
a11}{a12}{a13}{a14}}.
#var
################################## VARIABLES ##################################
#VARIABLE {foo}={{a1}{a2}{a11}{a12}{a13}{a14}{a3}{a4}{a5}{a6}{a7}{a8}{a9}{a10}}
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3796

PostPosted: Mon Aug 31, 2009 8:47 pm    Post subject: Reply with quote

It's not a bug, it's how associative arrays are supposed to behave. If you want stuff to stay in order use numbers, to do this more easily:
Code:

#list foo create {a} {b} {c} {d}
Back to top
View user's profile Send private message Send e-mail
louipc



Joined: 16 Jul 2006
Posts: 65

PostPosted: Mon Aug 31, 2009 11:37 pm    Post subject: Reply with quote

Well, the conflict lies in the fact that I explicitly created a #var, not a list but that #var was altered behind my back.

If I put in a certain value, I expect to be returned the exact same value when accessing that data in the same manner.
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3796

PostPosted: Tue Sep 01, 2009 9:34 am    Post subject: Reply with quote

#list is not supposed to behave like an associative array, but as an array, which seems to be what you want.

#variable behaves like an associative array when nesting.
Back to top
View user's profile Send private message Send e-mail
louipc



Joined: 16 Jul 2006
Posts: 65

PostPosted: Tue Sep 01, 2009 6:16 pm    Post subject: Reply with quote

No. I just want #var to behave like #var in all circumstances.
Store the exact string that I put between the first { and the last matching }.

Maybe another command or data type should be created for associative arrays, but I think it's inappropriate for #var to be making those alterations to the input.

More examples of inconsistent behaviour:
Code:
#var foo {{a}{b}          }
#OK. VARIABLE {foo} HAS BEEN SET TO {{a}{b}          }.
#var foo
#VARIABLE {foo}={{}{}{a}{b}}
#var foo {           {a}{b}          }
#OK. VARIABLE {foo} HAS BEEN SET TO {           {a}{b}          }.
#var foo
#VARIABLE {foo}={           {a}{b}          }
#var foo {{a}{b}          one two}
#OK. VARIABLE {foo} HAS BEEN SET TO {{a}{b}          one two}.
#var foo
#VARIABLE {foo}={{a}{b}{one}{two}}


This kind of stuff makes #variable very flimsy in my opinion.
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3796

PostPosted: Wed Sep 02, 2009 10:24 am    Post subject: Reply with quote

As long as you don't use multiple sets of braces, variables behave as expected.

When nesting and using trailing spaces the space is treated as an extra empty nest, I'll add a check for this since there's no support for empty variable names. Looks like you can also bypass nesting behavior with a leading space, I'll fix that as well since some people like to space things out and would still expect nesting to occur.


Looking for a loophole for you to use old school #forall behavior with variables I noticed you can use ; instead of {} to separate arguments, currently using ; in #forall results in an infinite loop however.

So I went ahead and changed #forall and #foreach to ignore spaces and accept both braces {} and the semicolon ; to separate arguments.

Updated the beta file with the changes.

Example:
Code:

#forall {bli;bla bla;\ blo;blu } {#showme (&0)}
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Bug Reports All times are GMT - 5 Hours
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
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group