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

extra invocations in #foreach (1.99.7 beta)

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



Joined: 11 Jul 2009
Posts: 64

PostPosted: Sat Aug 15, 2009 10:00 am    Post subject: extra invocations in #foreach (1.99.7 beta) Reply with quote

I'm invoking event_raise from my event code inside an action that fires on prompt, and it's giving me an infinite loop of spam. This happens both when no events are registered and when some are. Here's the output for an empty _events

Slightly modified event_raise to echo some output
Code:
#ali event_raise
{
  #showme in raise _events = ${_events} event = %1;

  #foreach {${_events[%1][]}} {handler}
  {
    #showme handler = $handler;
 
    event_eval {${_events[%1][$handler]}} {%0};
 
    #nop substitute the line below for the above to disallow dynamic actions.;
    #nop ${_events[%1][$handler]} %0;
  }
}


spam output

Code:
in raise _events =  event = prompt
handler = 0
Pardon?
in raise _events =  event = prompt
handler = 0
Pardon?
in raise _events =  event = prompt
handler = 0
Pardon?

With #var _events {} #foreach {${_events[%1][]}} {handler} runs the loop once with handler = 0.
Back to top
View user's profile Send private message
Shaiith



Joined: 11 Jul 2009
Posts: 64

PostPosted: Sat Aug 15, 2009 10:16 am    Post subject: Reply with quote

I still can't figure out why it loops when _events has things defined. below is what debug shows (and it's looping just like before, although without the handler = 0 case.

Code:
#DEBUG ALIAS {event_raise} {prompt}
#DEBUG ALIAS {event_eval} {{position_verify} {prompt}}
#OK. {_event_tmp_ali} NOW ALIASES {position_verify} @ {5}.
#DEBUG ALIAS {_event_tmp_ali} {prompt}
#DEBUG ALIAS {position_verify} {prompt}


Here's the output
Code:
in raise _events = {prompt}{{position_verify}{position_verify}} event = prompt
handler = position_verify
Pardon?
in raise _events = {prompt}{{position_verify}{position_verify}} event = prompt
handler = position_verify
Pardon?
in raise _events = {prompt}{{position_verify}{position_verify}} event = prompt
handler = position_verify
Pardon?


position_verify is defined as
Code:
#ali position_verify
{
  #if {("${lastpos}"!="${curpos}")
    && ("${curpos}" != "${pos_abbrev_${pos_intent}}")}
  {
    pound_send ${pos_intent};
  };
}


which does not make use of the argument provided at all, and was not causing issues before moving to 1.99.7 beta.
Back to top
View user's profile Send private message
Shaiith



Joined: 11 Jul 2009
Posts: 64

PostPosted: Sat Aug 15, 2009 10:19 am    Post subject: Reply with quote

hmmm, when I change things slightly the looping stops

Code:
in raise _events = {prompt}{{position_verify}{#showme %1 %2 %3}} event = prompt
handler = position_verify
prompt 


would calling an alias with extra arguments ie
position_verify prompt; when it doesn't use %1 cause issues?

Code:
position_verify prompt;
Pardon?


turns out it does.

Hmmm Any suggestions for ways to not have this happen? This seems like a bug.
Back to top
View user's profile Send private message
Shaiith



Joined: 11 Jul 2009
Posts: 64

PostPosted: Sat Aug 15, 2009 10:23 am    Post subject: Reply with quote

In fact when I pass arguments that aren't used those are in turn passed to the mud.

Code:
position_verify bounce
You bounce around with excitement!
Back to top
View user's profile Send private message
Shaiith



Joined: 11 Jul 2009
Posts: 64

PostPosted: Sat Aug 15, 2009 10:37 am    Post subject: Reply with quote

The empty list and foreach problem comes down to differentiating between
Code:
#foreach {${_list[]}} i {#showme $i}
0

#foreach {${_list2[]}} i {#showme $i}
0

#var _list
#VARIABLE {_list}={{0}{foo}}

#var _list2
#VARIABLE {_list2}={}
Back to top
View user's profile Send private message
Shaiith



Joined: 11 Jul 2009
Posts: 64

PostPosted: Sat Aug 15, 2009 10:39 am    Post subject: Reply with quote

They are slightly different

Code:
#showme ${_list[]}
{0}
#showme ${_list2[]}
0


but in #foreach those two cases work the same.
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3796

PostPosted: Sat Aug 15, 2009 1:16 pm    Post subject: Reply with quote

I guess I could make an invalid $variable[] call return {} instead of {0} and have #foreach {} do nothing.

Would that be helpful?
Back to top
View user's profile Send private message Send e-mail
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3796

PostPosted: Sat Aug 15, 2009 6:34 pm    Post subject: Reply with quote

I went ahead and changed #foreach {} to not do anything, and using $variable[] on an empy list printing an empty string.

That looks like the most useful behavior to me. #foreach {{}} still works.
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