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
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Sat Dec 01, 2007 2:16 pm   

[2.14] Bad function reference leaves parameters on the stack
 
I am looking at using functions as a way of handling package dependencies. The idea being that I would do
Code:
#IF (@function(args)="") {handle it in this package} {they have my other package with the enhanced feature}
This should work because a nonexistent variable/function returns a null when referenced. The bug with doing this is that the null return does not include the (args) portion.

Procedure
1. Launch CMud
2. Close Sessions window (ESC)
3. Enter at the command line
Code:
#SHOW @BadFunctionReference(This should be eaten too)
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Tech
GURU


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

PostPosted: Sat Dec 01, 2007 4:30 pm   
 
I see this behavior too. I believe this should be handled by treating the function reference as a literal if and the rest of the string evaluated as normal. However you'd still get the compressed text because the parentheses still to evaluate the string.

Try this to see what I mean.
Code:
#SHOW (This should be eaten too)
_________________
Asati di tempari!
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Sat Dec 01, 2007 4:54 pm   
 
If we do this
Code:
#VAR a {3};#SHOW @a(test)
then we see that a 3 is displayed. There really is no implicit concat when a variable/function is followed by "(anything)", it is always treated as parameters to the referenced variable/function. I don't actually see that an implicit concat should become the rule when the variable/function does not exist.

Perhaps it would be possible to make @{Function(args)} a valid syntax. Currently it gives a parsing error on the opening parenthesis. This might function as a compromise if anyone thinks the current behavior is good. Also adding this syntax would allow for indirect function calls which is currently quite difficult.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Tech
GURU


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

PostPosted: Sat Dec 01, 2007 10:08 pm   
 
Ok.. I see your point. At the risk of a side track, why are you using funtions to handle package dependencies instead of use %class() to check for the existence of the module your interested in.
_________________
Asati di tempari!
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Sat Dec 01, 2007 11:18 pm   
 
I don't mind the side track. The idea behind doing it is that I am going to have some packages published to everyone, and some published to a private group. Some of the packages published to everyone will have other features that become available when the private package is present. Some things simply won't be handled in the private package, since they are available in the public package. In most cases I plan on using something like the if in my first post. The functions will generally be doing the enhanced feature rather automatically so more often then not I will simply be checking for a null return and doing a basic version.

The other reason is that doing the %class will have to preform a name lookup for that class, then return the enabled state of it. After that I would use a function or alias incurring a second name lookup and search. If I can just use a function in the first place there is only 1 name search, a disabled or nonexistent one will return null which means 1 less #IF too. In simplest terms I am aiming at shaving a few milliseconds off from the processing time of splitting all my scripts into distributable packages, without replicating code all over the place.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Sun Dec 02, 2007 1:01 pm   
 
Couldn't the OnLoad of the public package do the %class lookup and then set a variable? You could then check the variable each time instead of doing the function return.
_________________
Taz :)
Reply with quote
Zugg
MASTER


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

PostPosted: Mon Dec 03, 2007 6:22 pm   
 
Original problem confirmed and added to bug list. I agree that undefined functions should "eat" their arguments too. I'm not going to try and do any fancy implied concat in this case.
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