Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #31  
Old 06-23-2007, 10:09 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
By function inheritance I mean that when you call function() in a child, it's possible to also call it in the parent.

e.g.

function() is called.

function() calls parent::function()

[parent::function() calls grandparent::function()]

then whatever has to happen in function() occurs.
__________________

Coming soon (Hopefully:P)
Reply With Quote
  #32  
Old 06-23-2007, 10:53 PM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by JkWhoSaysNi View Post
By function inheritance I mean that when you call function() in a child, it's possible to also call it in the parent.
Typically in OOP, this is not the desired effect. The parent function should only be called if the child does not have a function of the same name (should be a virtual function).
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #33  
Old 06-23-2007, 11:49 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
Not true. In a lot of OO lanuguages in the child class you can choose to redefine (inherit) or override (no inheritance) or even in some languages, undefine the function.

E.g. in Eiffel (which probably has one of the best OO models going) to allow for real multiple inheritance you can choose to rename, redefine or undefine (or a few others iirc)
code example

PHP Code:
class
 
child
inherit
 parent
  redefine functionName
end
feature 
 functionName 
  
do 
    
precursor --run the function of the same name in the parent
     
--then do whatever
  end 
Similar functionality is available in Delphi.
__________________

Coming soon (Hopefully:P)
Reply With Quote
  #34  
Old 06-24-2007, 01:11 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by JkWhoSaysNi View Post
rename, redefine or undefine
Okay, well perhaps I misunderstood, but none of these seem to be of real interest for graal datatypes joining classes.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #35  
Old 06-24-2007, 11:22 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
Inheritance in Graal doesn't work like that, you're not supposed to overwrite functions or variables. You're just supposed to extend the functionality of the supertype without changing it or complete its functionality if the supertype is abstract. If you observe the object type structure on the Wiki you'd notice that functions and variables are never overwritten by subtypes.

An example of this is the TXMudContainer type on Aeon. Its abstract and gives all subtypes (most especially TXMudPlayer) the ability to hold items. This allows for easy moving of item objects between players, npcs, and containers in the world like barrels and crates.

One of the tools I find invaluable for modularity and object types is this function, triggerAll():
PHP Code:
public function triggerAll(eventnameparam0param1param2param3param4param5param6param7param8param9) {
  
this.scriptlogmissingfunctions false// for no RC errors.
  
  
temp.0;
  
temp.list = this.joinedclasses;
  
  list.
remove("util_triggerall"); // Class with this script
  
makevar(eventname "_base")(param0param1param2param3param4param5param6param7param8param9);
  for (
0< list.size(); ++) {
    
makevar(eventname "_" @ list[i])(param0param1param2param3param4param5param6param7param8param9);
  }

I don't find the classname::functionname() syntax too reliable.
__________________
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 05:12 PM.


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