![]() |
Define your own variable types
PHP Code:
|
Really, really nice :D
|
I'm confused, what is that supposed to be doing? Why are you defining varType as an array then calling it as a function? And what does this have to do with Object Types?
|
Quote:
PHP Code:
|
I still, pretty much have no clue, what you're talking about PFA.
|
This has nothing to do with custom object types. Stop trying to be cool -.-
You have no idea what I'm talking about. |
e.g.,
PHP Code:
Quote:
So tell me, what do you want? Something wrapped in a useless macro? And the array thing I typed up real fast and didn't catch until after I posted. |
1 Attachment(s)
I take that back, interesting, but no cigar. Offers no form of inheritance or any of the neat features of actual graal object types.
Heres my solution to the problem: |
Quote:
e: Not to mention it doesn't have to be TStaticVar in the definition. You can use something more upper-level if you need specific inheritance. |
Does your mind exist in Candy-Land or something? x-x
Quote:
Quote:
|
Quote:
Quote:
Quote:
|
Quote:
Quote:
Edit: I just tested, apparently joinedclasses can be written now, my rage is insurmountable. Oh well, my system is still superior. |
Tol made a good contribution. Can someone point out to me why it was neccessary to start a big argument with name calling? By someone, perhaps Inverness is best suited to answer.
It is just this over and over on these forums anymore... |
Quote:
|
Here is a little something I whipped together after my recent discovery.
PHP Code:
Quote:
Quote:
|
Quote:
I find this to work too: PHP Code:
|
Quote:
I don't like how your class names and function names are the same. !pissed! |
Interesting ideas. I can't seem to get it to work. I'm trying to implement function inheritance but I can't even get your example to work:
PHP Code:
Any ideas? |
Hm, you're looking for object inheritance right Knight? :O
|
Quote:
|
didn't help. I can't get it to work at all.
|
I don't know about function inheritence but class inheritence works fine because joinedclasses can be written directly, just use classes.
|
Yes, i suppose it's possible
e.g. parent class PHP Code:
PHP Code:
|
Quote:
And as for the function inheritance thing, I've been messing around with it too. Saving a function to a variable seems to give it a null value (try echo), so that's all you get when you try to copy it from something else. It still comes up in the var names, but it's just 0. |
I wouldn't use a function to return a custom object either, since function's cant be made global by anyone but Stefan. Using my method, it creates objects with the typical global name that can be used anywhere without the need for joining classes to access the functions and such.
PHP Code:
|
Wow, i looked at your code on the previous page but couldn't really see what it did.
That is very nice Inverness. I don't understand how it makes them usable anywhere though. |
TStaticVar's by nature are made global objects when you name them I believe.
|
Quote:
The only problem I'm seeing with my method is that onCreated() is not called until after the function that is creating the object. PHP Code:
PHP Code:
Basically I'm requesting an event onJoinedClass or something that is called as soon as Graal joins the class script and before the next class is joined so I can execute functions that need to be done before continuing. If something like this already exists by all means point it out please :) |
I've updated your script so it calls things as you'd expect. Before onCreated was only getting called in the parent class, not both the parent then the child class.
Here: PHP Code:
parent::function where parent is a string variable because it expects a class name before ::. edit: Although that does the onCreateds in the right order, when you go to call a function on the object it will look for it in the parent class first. This is a problem, I don't think it's possible to have onCreated's in the correct order *and* have function calling work upwards. So either: onCreated gets called in the child then the parent and functions get called in the parent when the same function name exists in both the parent and the child or: onCreated gets called in the parent then the child (as you'd hope) and functions are looked for in the parent before the child. |
onCreated gets called in each joined class in the order that they're joined. The super variable in the function is just an object to copy class names from initially so you dont have to retype all the class names again in the area that calls maketype().
Function inheritance works fine like this, there is no reason to change the script. Observe: PHP Code:
PHP Code:
|
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. |
Quote:
|
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:
|
Quote:
|
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:
|
| All times are GMT +2. The time now is 10:15 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.