Graal Forums  

Go Back   Graal Forums > Development Forums > Future Improvements
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-14-2007, 12:10 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Global Functions

Why haven't they been implemented yet? We even have function objects now but no global functions yet, its not that hard to do I'm sure. Don't like using classes for things that should be global anyways.
__________________
Reply With Quote
  #2  
Old 09-14-2007, 12:34 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
I am not sure how you magically expect global functions to work internally in the script engine.

Just use classes. :/ They aren't that inconvenient.
__________________
Skyld
Reply With Quote
  #3  
Old 09-14-2007, 01:09 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Skyld View Post
I am not sure how you magically expect global functions to work internally in the script engine.
We have dynamic global variables and objects, why not functions? I doubt it would take that much of an adjustment. Just make the function lookup look at something else between the local functions and the globals. Perhaps the Control-NPC? I had originally thought functions in there should be global by default but was rather disappointed.
Quote:
Originally Posted by Skyld View Post
Just use classes. :/ They aren't that inconvenient.
Class functions show up in getVarNames() and getFunctions(), icky. Global functions are just easier since you don't need to remember what class the thing is in or maintain classes so they match up to a system as you update it.
__________________
Reply With Quote
  #4  
Old 09-14-2007, 10:18 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Global functions are techincally possible, but they make programming actually much harder. It is making it even harder to find where the function is declared. We already have global variables, and we should not repeat that mess with global functions. It is much cleaner to put the functions in an npc and call NPCName.function(), or put it in a class.
Reply With Quote
  #5  
Old 09-14-2007, 04:13 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Stefan View Post
Global functions are techincally possible, but they make programming actually much harder. It is making it even harder to find where the function is declared. We already have global variables, and we should not repeat that mess with global functions. It is much cleaner to put the functions in an npc and call NPCName.function(), or put it in a class.
I suggested only functions in Control-NPC would be only ones qualifying as global, it would not be difficult at all to find out where they're declared if that is the case.
PHP Code:
// Script
function onCreated() {
  
addItem("sword"1);
}
// Control-NPC
public function addItem(archcount) {
  
player.mud.addItem(archcount);

Simple enough.

I'm not suggesting global functions be declared the same way that global variables are (since that would be a horror as you're saying), just that when the Control-NPC is compiled its functions added to the global list or something.

So basically, for the function lookup, if there is no prefix it would look at:
Local Object (this.) -> Control-NPC -> Static Globals.
__________________

Last edited by Inverness; 09-14-2007 at 06:22 PM..
Reply With Quote
  #6  
Old 09-14-2007, 04:38 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
could be nice
__________________
Reply With Quote
  #7  
Old 09-14-2007, 10:32 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Why not simply use MyFunctionsNPC.function() ?
Reply With Quote
  #8  
Old 09-14-2007, 10:40 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by Stefan View Post
Why not simply use MyFunctionsNPC.function() ?
Scripter's are lazy, and classes is just a hazzle when there's alot of them

It could be nice with global functions that would make it so you couldn't make more functions with the same name, for example when you make another onCreated() event or make two functions with the same name, it will cause an error

PHP Code:
Mud.additem("sword"1);
additem("sword"1);
player.mud.additem("sword"1);
Mud_Object_Player_Chompy.additem("sword"1); 
etc.. in the end you get confused, but that was kinda a bad example, but if you could create global function it would help for example the main systems of the server, for example the mudlib that servers lately are interested in.
__________________

Last edited by Chompy; 09-14-2007 at 11:31 PM..
Reply With Quote
  #9  
Old 09-14-2007, 11:00 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Stefan View Post
Why not simply use MyFunctionsNPC.function() ?
Yes it works and I do use it in the cases where I need to, but its not preferred when you have lots of different groups of functions in different weapons/objects or classes. And it just looks bad next to the globals that Graal has

For the classes, rather than having to join small utility classes to everything that uses it you can just join it to the Control-NPC and then everything can use it, including the random LAT with little knowledge of scripting.

Having globals puts everything on the same plate and would make it easier for people unfamiliar with the system. I don't think its asking much to make public functions in the Control-NPC global (and those with a global_ prefix in the function name only?). Since they would only work in the Control-NPC it would the massive chaos of someone not knowing where the global function is declared.
__________________

Last edited by Inverness; 09-15-2007 at 12:06 PM..
Reply With Quote
  #10  
Old 09-22-2007, 01:19 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Bump

I would appreciate a response.
__________________
Reply With Quote
  #11  
Old 09-22-2007, 06:17 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Still seeing it as bad coding style.
Reply With Quote
  #12  
Old 09-22-2007, 10:41 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Stefan View Post
Still seeing it as bad coding style.
The negatives you stated in first post are invalidated by using the Control-NPC for global functions only.

I don't see how its bad coding style to have a single additional location in the function-lookup process.

Local Object -> Control-NPC -> Static Globals

There is nothing confusing about that. It puts all the globals in one bag so you can't miss them.
__________________
Reply With Quote
  #13  
Old 09-24-2007, 02:44 AM
Kyranki Kyranki is offline
Freelance Coder
Join Date: Aug 2007
Location: At the end of the rainbow, in the pot of gold.
Posts: 202
Kyranki is on a distinguished road
Send a message via AIM to Kyranki Send a message via MSN to Kyranki
I mean, they would only be placed in the Control Npc so that it won't be a hard to find the functions when necessary.

I completely agree with this as it would be a nice addition to servers period
__________________
Stan.
Reply With Quote
  #14  
Old 09-24-2007, 04:26 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
I don't think Stefan should honestly have to go through that just to save yourself from having to join a class or putting a weapon name in front of the function. (i.e. "FunctionsWeapon".doThingy())
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #15  
Old 09-24-2007, 09:17 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by Kyranki View Post
I mean, they would only be placed in the Control Npc so that it won't be a hard to find the functions when necessary.

I completely agree with this as it would be a nice addition to servers period
There's no point. It takes almost no effort to type (@ "Control-NPC").functionname(); or this.join("classname");, and adding things like this just promotes laziness and makes things more complicated. :/
__________________
Skyld
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:22 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.