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
  #16  
Old 09-24-2007, 11:26 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 Skyld View Post
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. :/
Those are both bad reasons. Classes get disorganized easily if you have many utility functions and things like I do and I don't want the functions from the class being added to the object for stuff like that.

Having global functions would make it easier on those who are unfamiliar with the system. Its called encapsulation and I try to practice it in just about everything I do. I'd love to be able to reorganize how something works and still have other scripts on the server work correctly because of the global functions. That is why GS1 still works, yes?

And please explain how it makes things more complicated, I can't see anything complicated with adding another space to the function lookup. It seems like you're worrying about how badly newbie scripters can **** it up instead of focusing on the good and thats irritating. Having global functions easily accessible to novice scripters would just make things easier.

So far I've seen bad reasons as to why a simple new feature shouldn't be added to gscript. Graal has a crapload of global functions and I suppose thats just too much for us mortal scripters to handle.
__________________
Reply With Quote
  #17  
Old 09-25-2007, 02:40 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Inverness View Post
Those are both bad reasons. Classes get disorganized easily if you have many utility functions and things like I do and I don't want the functions from the class being added to the object for stuff like that.
I'd rather a messy class over a messy Control-NPC
Reply With Quote
  #18  
Old 09-25-2007, 11:28 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 Twinny View Post
I'd rather a messy class over a messy Control-NPC
Control-NPC can join classes.
__________________
Reply With Quote
  #19  
Old 09-26-2007, 07:54 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Inverness View Post
Control-NPC can join classes.
So can everything other object which allows access to functions which, in turn, provides your precious 'global functions'. So instead of asking for an update which lets you use one less word and a dot, how bout we use what is already there? And before you go all, "but lol global functions already exist!", I'd say there'd be quite a difference between hard coded global functions and gscript ones. Inheritance is more likely. (achieveable by classes!).

Request actual features...not just solutions for pure lazyness. Also, don't go running around calling it 'encapsulation'. Encapsulation is like the process of encapsulating a udp/tcp header/data into an ip packet. For gscript, encapsulation would be more like taking a piece of data and adding it to a self-sufficient container...which undermines the point of 'global functions'. Funilly enough, this could be more readily achieved with classes.

When requesting something, try explaining what it will achieve and how the current system can't easily achieve the same effect

Last edited by Twinny; 09-26-2007 at 08:28 AM..
Reply With Quote
  #20  
Old 09-26-2007, 11:31 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
You know, I plan to go into game development/programming in my future and Graal is about the best amateur platform there is, however it makes it really hard to practice OOP principles sometimes.
Quote:
Originally Posted by Twinny View Post
So can everything other object which allows access to functions which, in turn, provides your precious 'global functions'. So instead of asking for an update which lets you use one less word and a dot, how bout we use what is already there? And before you go all, "but lol global functions already exist!", I'd say there'd be quite a difference between hard coded global functions and gscript ones. Inheritance is more likely. (achieveable by classes!).
Wrong, Global functions are separate from the existing object types and not inherited, they're global. They're not involved with inheritance at all. Inherited functions are part of the local object. Thats obvious from reading the Wiki.
Quote:
Originally Posted by Twinny View Post
Request actual features...not just solutions for pure lazyness. Also, don't go running around calling it 'encapsulation'.
There is a difference between joining a class and adding another space to the function lookup.
Quote:
Originally Posted by Twinny View Post
Encapsulation is like the process of encapsulating a udp/tcp header/data into an ip packet. For gscript, encapsulation would be more like taking a piece of data and adding it to a self-sufficient container...which undermines the point of 'global functions'. Funilly enough, this could be more readily achieved with classes.
"Encapsulation describes the ability of an object to hide its data and methods from the rest of the world - one of the fundamental principles of OOP (Object Oriented Programming)."

Encapsulation means people should be able to use my or anyone else's scripts without knowing how they work, this is the reason I want catchEvent() to work with dynamic function events.

Classes add their functions to the local object, something I don't want, or else I would simply put all the functions I consider "global" and join it to everything, however that would screw up the getfunctions() and such. So instead I divide it up between classes and it becomes disorganized for simple functions such as putnpc3() that don't really fit in a category (and if that happens I just drop it because there is no simple way to make it available everywhere), it also makes it harder on new scripters to the server. I'd rather not be the sole scripter on the server that constructs the main system and if I want my systems to work with others well, encapsulation should be practiced.
Quote:
Originally Posted by Twinny View Post
When requesting something, try explaining what it will achieve and how the current system can't easily achieve the same effect
Like I believe I said, it will make it easier for new scripters or scripters that aren't myself since they don't know how the server ticks, and having all the functions available in one space would make it easier for them since if I reorganize how things work internally they wont get confused. I'd love to be able to present a list to a new scripter or such and tell them thats how you work the server.

Also I like sharing alot of the things I make and global functions would allow something to interface with scripts on another server easily.

Its like standardization, many servers have different ways of organizing their scripts that are good or bad and having custom globals allows different things to work together easier by providing a common space for them to interact.


Its irritating really, I ask for a simple single addition to the function look up and nobody can actually give a good reason why it shouldn't be included and actually explain it at the same time.
__________________

Last edited by Inverness; 09-26-2007 at 11:50 AM..
Reply With Quote
  #21  
Old 09-26-2007, 12:22 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Inverness View Post
"Encapsulation describes the ability of an object to hide its data and methods from the rest of the world - one of the fundamental principles of OOP (Object Oriented Programming)."
Which is achievable like so
PHP Code:
class CPoly {
    
int xy;
  public:
    
void set_vars (int,int);
    
int getarea () {return (x*y);}
}; 
With that, only the local object can access x,y and everything else will have to use the two functions to interact with the variables. This is an example of how you hide data/methods in OOP languages. Global functions do not promote clean OOP programming standards.

Unless Stefan implements protected variables sometime soon (something I actually suggested a while ago), this isn't possible in gscript and global functions don't fall under the encapsulation umbrella.

Encapsulation isn't referring to protecting your code from other coders . You could achieve the same effect by having a class with private functions and make sure only you can read the class. It's making sure you follow OOP rules and only allow the local class have access to it's variables.

Nothing should ever need access to everything at any point. Classes can be nicely labeled ("mud_functions", "magic_functions"), and new scripters will be able to find what they are looking for alot easier than sifting through a massive Control-NPC script. This also means that an item object can't turn a player into a duck and plants don't spit out weapons. Global functions are just messy and lazy.

And yes, I realize there are hard coded global functions. I was suggesting that you could happily follow the concept of inheritance using classes to achieve the same effect...alot more cleaner as well.

Last edited by Twinny; 09-26-2007 at 12:34 PM..
Reply With Quote
  #22  
Old 09-26-2007, 01:04 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 Twinny View Post
Which is achievable like so
PHP Code:
class CPoly {
    
int xy;
  public:
    
void set_vars (int,int);
    
int getarea () {return (x*y);}
}; 
With that, only the local object can access x,y and everything else will have to use the two functions to interact with the variables. This is an example of how you hide data/methods in OOP languages. Global functions do not promote clean OOP programming standards.
Don't start comparing GScript to other languages. Btw, I'm pretty sure I never said global functions were part of encapsulation. They're for compatibility and interface. Which is something needing on Graal because of the lack of standards.
Quote:
Originally Posted by Twinny View Post
Unless Stefan implements protected variables sometime soon (something I actually suggested a while ago), this isn't possible in gscript and global functions don't fall under the encapsulation umbrella.
See above.
Quote:
Originally Posted by Twinny View Post
Encapsulation isn't referring to protecting your code from other coders . You could achieve the same effect by having a class with private functions and make sure only you can read the class. It's making sure you follow OOP rules and only allow the local class have access to it's variables.
No, what I mean by encapsulation is that I could have others use my scripts with full functionality without knowing how they work. I don't know what you mean by limited variable access considering this is GScript we're talking about.
Quote:
Originally Posted by Twinny View Post
Nothing should ever need access to everything at any point. Classes can be nicely labeled ("mud_functions", "magic_functions"), and new scripters will be able to find what they are looking for alot easier than sifting through a massive Control-NPC script.
Uh, first of all, the global list would be written down in a format like in the Wiki in a commented-out weapon labeled *FunctionList or so, second, there is a find button. It would be no different than looking for the global functions on the Wiki, except mine would actually be documented
Quote:
Originally Posted by Twinny View Post
This also means that an item object can't turn a player into a duck and plants don't spit out weapons.
I don't see how thats even related to global functions, but that would be interesting to do.
Quote:
Originally Posted by Twinny View Post
Global functions are just messy and lazy.
I have yet to be convinced as to why, considering what I would use global functions for. Its not like I'm going to make everything global or something. It wont be nearly as messy as the hard-coded global functions already are.
Quote:
Originally Posted by Twinny View Post
And yes, I realize there are hard coded global functions. I was suggesting that you could happily follow the concept of inheritance using classes to achieve the same effect...alot more cleaner as well.
Like I said, using classes aren't like adding another function lookup space. I don't want certain functions added to the function/variable list of the object.

Edit: These are the functions I would make global on Val Dev:
PHP Code:
clientFunction()
clientFunction2()
error()
import()
mudAddItem()
mudApplyItem()
mudFindItem()
mudRemoveItem()
putNpc3()
reflectObject()
//#CLIENTSIDE
addHistoryMsg()
addMsg()
addObject()
addReflection()
clearMsgs()
consoleMsg()
disconnect()
hideHud()
import()
reconnect()
refreshInventory()
serverFunction()
serverFunction2()
showCharacterSelect()
showHud()
showInputDialog()
showInventory()
triggerAllObjects()
triggerAllWeapons() 
It doesn't look very messy to me.

If you look at the Wiki, you'd see over 100 global functions that GK has added just for itself, many of which point to functions in objects in the same manor that I would do myself, obviously its not so messy if GK does it.
__________________

Last edited by Inverness; 09-26-2007 at 01:42 PM..
Reply With Quote
  #23  
Old 09-26-2007, 01:39 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Inverness View Post
If you look at the Wiki, you'd see over 100 global functions that GK has added just for itself, many of which point to functions in objects in the same manor that I would do myself, obviously its not so messy if GK does it.
GKs mud functions are hard coded into the NPC-Server

Quote:
Originally Posted by Inverness View Post
Uh, first of all, the global list would be written down in a format like in the Wiki in a commented-out weapon labeled *FunctionList or so, second, there is a find button. It would be no different than looking for the global functions on the Wiki, except mine would actually be documented
Nothing stopping you from doing this with classes. It can be organized in exactly the same way .

And you're right, gscript is not like other languages which makes it confusing when you bring up OOP programming concepts like, "encapsulation" and even quote them then try to relate it to different concepts .

Pretty sure the burden is on you to prove why these updates are necessary: not the other way around.
Reply With Quote
  #24  
Old 09-26-2007, 01:46 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 Twinny View Post
GKs mud functions are hard coded into the NPC-Server
Those are global functions pointing to object functions, obviously you're not understanding dynamic globals would do the exact same thing.
Quote:
Originally Posted by Twinny View Post
Nothing stopping you from doing this with classes. It can be organized in exactly the same way .
How many times do I have to say it? Classes are unnecessary for a small amount of functions, especially when I don't want them added to the function/variable list for the object.
Quote:
Originally Posted by Twinny View Post
And you're right, gscript is not like other languages which makes it confusing when you bring up OOP programming concepts like, "encapsulation" and even quote them then try to relate it to different concepts .
Same with your private variables. I explained my reason for practicing Encapsulation in an earlier post.
Quote:
Originally Posted by Twinny View Post
Pretty sure the burden is on you to prove why these updates are necessary: not the other way around.
I do not think so. The 'update' is an addition of one object to the function look up, something so simple is easy to add (or should be) and would require no/minimal effort so there should really be no reason NOT to do it.

Please tell me why GK is allowed to have global functions pointing to object functions yet we're not? When they're certainly possible dynamically as Stefan has said. I'm going to be honest and say absolutely nothing will convince me why Global functions shouldn't be allowed until this is explained.
__________________

Last edited by Inverness; 09-26-2007 at 02:27 PM..
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 11:36 PM.


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