Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Future Improvements (https://forums.graalonline.com/forums/forumdisplay.php?f=10)
-   -   super functions? (https://forums.graalonline.com/forums/showthread.php?t=74081)

Novo 05-20-2007 10:53 AM

super functions?
 
Considering that functions are now variables... Wouldn't it be easy to implement this?

PHP Code:

function echo( text )
{
  
super::echo( format("[%s]: %s"this.nametext ) );



killerogue 05-20-2007 04:27 PM

What exactly would these super functions do?

xXziroXx 05-20-2007 04:28 PM

Quote:

Originally Posted by killerogue (Post 1309901)
What exactly would these super functions do?

I'm not sure, but probably overriding an existing function with that name.

Tyhm 05-20-2007 08:20 PM

Use the old function from within the new function I guess.
Bad idea. Don't override. It makes for ugly development later on, when those who inherit your code try and use the original function without thinking "Oh yeah, grampa redefined "echo", I need to use "super::echo". Just don't, name yours "echo2" and have done. Mass replacement's not hard.

Twinny 05-21-2007 12:45 AM

Next he'll ask for overloaded functions ^^.

cbk1994 05-21-2007 01:11 AM

What would be nice is if we could access the code that each built-in function uses (or does it use built-in code, not gs2?) and ever nicer to be able to modify.

Deadly_Killer 05-21-2007 01:52 AM

well logically, if it was in a class called super and you joined it.

you could do:
super::echo(stuff);

I think.

JkWhoSaysNi 05-21-2007 02:31 AM

Quote:

Originally Posted by Twinny (Post 1310034)
Next he'll ask for overloaded functions ^^.

Now that would be nice.

Novo 05-21-2007 02:45 AM

Quote:

Originally Posted by Deadly_Killer (Post 1310044)
well logically, if it was in a class called super and you joined it.

you could do:
super::echo(stuff);

I think.

PHP Code:

function onCreated()
  {
  
this._oldEcho this.echo;
  }

function echo( 
text )
  {
  return 
this._oldEchoformat("[%s]: %s"this.nametext ) ) );
  } 

That's be what I'd have to do... Which is a pain... :(

Deadly_Killer 05-21-2007 03:57 AM

I have no idea what these function objects are and am yet to play with them until I get a decent explanation on what I could possibly do with them.

Inverness 05-21-2007 11:25 PM

You cant overload functions since everything is TGraalVar in the basic sense. You could have an if statement in a function to check the type of the parameter, but doing that is bad (I've tried it) since variables aren't always what they're supposed to be. Better to sick with separate functions. Though I would like it if the params array was present for all functions and not just actions.

What I would like is Custom Object Types :) And the ability to add global functions.

I have yet to see an actual demonstration of function objects though I would like it very much.


All times are GMT +2. The time now is 02:23 AM.

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