Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-21-2008, 02:26 PM
Darklux Darklux is offline
Petrification of a Newbie
Darklux's Avatar
Join Date: Dec 2002
Location: Dortmund, Germany
Posts: 1,375
Darklux is a jewel in the roughDarklux is a jewel in the rough
Send a message via ICQ to Darklux Send a message via AIM to Darklux Send a message via Yahoo to Darklux
Difference Java/C++ <-> GS2

Hey,

Iam thinking of learning GS2.

I had Java and C++ in School and already some in University, so I just wanted to ask where the main differences lie.

- Lux
Reply With Quote
  #2  
Old 01-21-2008, 03:02 PM
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
My C/C++ and Java are both quite scratchy, so forgive me if this is not totally accurate, but from what I remember:

C/C++ is statically typed (in terms of variable data types), GScript uses variant types which adapt to the type of data automatically.

Classes are very different in GScript to Java. Obviously in C classes do not exist, and I cannot say about C++ since I don't know enough about it. In GScript typically you implement class-like functionality using object joins, which are dynamic. You can "invent" class-like functionality in GScript by using these joinable class scripts, and also by using function prototyping and such.

You don't think about allocation in GScript, since that is all done by the engine, whereas C/C++ (and maybe Java to an extent), you must set aside space to work with before you work with it.

GScript uses built-in event-handling functions quite heavily to handle user/player interaction, whereas this functionality would not usually be implemented by default in C/C++.

Scripts in GScript work quite heavily on an instance basis, i.e. an NPC, weapon script, GANI script, etc, which means that extra functionality like trigger and such are added to allow communication between these instances. Similar to Java's object instances, I guess.

Flow control is pretty much identical (break, continue, return), as are many of the syntax structures (for, while, do, if), functions are defined in much the same way (with the function keyword instead of the expected datatype), and functions are called in the same way. Variable scoping isn't really vastly different to Java, not sure about C/C++ though without checking.

GScript is quite a lot more like ECMAScript/JavaScript in terms of structure though.
Reply With Quote
  #3  
Old 01-21-2008, 03:13 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
One thing I like about GS2 that Java doesn't have (but I would not want Java to have; would makes things incredibly complicated.

You can do something like this in GS2:
PHP Code:
function onFoo()
{
  if ( 
isFooing )
  {
    return;
  }
  echo( 
"No, you are not fooing ..." );

Whereas in Java you would need to do something like this to get out of a function easily:

PHP Code:
public boolean onFoo()
{
  if ( 
isFooing )
  {
    return 
false;
  }
  
System.err.println"You are not fooing ..." );
  return 
false;

Makes it much easier to leave functions when you don't need to specify everything.

Also, when comparing strings you CAN use ==.

PHP Code:
if ( foo == no )
{
  echo( 
"not foo" );

vs.

PHP Code:
if ( foo.equalsno ) )
{
  
System.err.println"not foo" );

Also, I find it nice that you can handle conversions much easier- the system does it for you! What I mean is that an int is a double is a float, etc, where in Java you need to do conversions int.readDouble() ...

Just a few things that are different in Java vs GS2
__________________
Reply With Quote
  #4  
Old 01-21-2008, 09:55 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
C/C++ struct functionality can be replicated.
PHP Code:
function somestruct() {
  
temp.var = new TStaticVar();
  
with (temp.var) {
    
// definitions
  
}
  return 
temp.var;
}
somestruct(); 
vs.
PHP Code:
typedef struct {
  
// definitions
somestruct;
somestruct A
C++ classes, however, cannot be fully replicated (though I intended to request something that would... And then my computer died).

Classes in GS2 can be thought of as a mixture of #include and a class declaration. Joining a class gives access to its code and in ambiguous situations, should be called like class::func();.

I know jack about java, though. Sorry if this isn't a good explanation, it's very hard to type on an iPod.
__________________
◕‿‿◕ · 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 :/

Last edited by Tolnaftate2004; 01-22-2008 at 07:06 AM..
Reply With Quote
  #5  
Old 01-21-2008, 10:33 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Tolnaftate2004 View Post
I know jack about java, though. Sorry if this isn't a good explanation, it's very hard to type on an iPod.
You wrote that whole post on an iPod ... ?

I couldn't type that much in a day on my iPhone
__________________
Reply With Quote
  #6  
Old 01-21-2008, 11:10 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
Why do we need C++ classes again?
__________________
Reply With Quote
  #7  
Old 01-22-2008, 07:04 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 Inverness View Post
Why do we need C++ classes again?
Data hiding, encapsulation.

@ cbkbud... My plane home was delayed; I had nothing better to do.
__________________
◕‿‿◕ · 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
  #8  
Old 01-22-2008, 11:20 AM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Quote:
Originally Posted by Tolnaftate2004 View Post
Data hiding, encapsulation.
I did replicate Java's class system... Although data-hiding isn't really possible ( all variables are public by restriction ). None-the-less, I pretend that it isn't public.

I posted it on the forums some time ago:
http://forums.graalonline.com/forums...ad.php?t=77835

( Java class system doesn't include multiple inheritance, although that is little unimportant with the advent of join's. )

Additionally, GS2 isn't type-casted in the traditional sense... I find that non-typed languages are harder to work with: They force us to follow good coding practices.
Reply With Quote
  #9  
Old 01-22-2008, 07:31 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 Novo View Post
I did replicate Java's class system... Although data-hiding isn't really possible ( all variables are public by restriction ). None-the-less, I pretend that it isn't public.
Right now, one could make member functions "protected/private" with some clever thinking and the right code. Variables are a different case.
__________________
◕‿‿◕ · 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
  #10  
Old 01-22-2008, 11:33 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
Maybe private variables in Graal should be done like in Python where if the variable name starts with _ then its private.

this._varname == private
this.varname == public

That seems like the most painless way to me.
__________________
Reply With Quote
  #11  
Old 01-23-2008, 01:07 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Inverness View Post
Maybe private variables in Graal should be done like in Python where if the variable name starts with _ then its private.

this._varname == private
this.varname == public

That seems like the most painless way to me.
I would rather see thisr. or even this.protected.
__________________
Reply With Quote
  #12  
Old 01-23-2008, 01:42 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
thisr. will not happen considering you would need thisor. and stuff like that and it would just become a giant pain. Something like this.private. might be better however having subvariables for variables that aren't objects is kinda weird and I don't think it would be good to go into that.

I still think my suggestion is best.
__________________
Reply With Quote
  #13  
Old 01-23-2008, 03:03 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Inverness View Post
thisr. will not happen considering you would need thisor. and stuff like that and it would just become a giant pain. Something like this.private. might be better however having subvariables for variables that aren't objects is kinda weird and I don't think it would be good to go into that.

I still think my suggestion is best.
What is thisor exactly?
__________________
Reply With Quote
  #14  
Old 01-23-2008, 03:15 AM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
I think the best solution for private variables is just treating them as private. The convention you use for denoting a private variable could help you.

I basically treat all variables as private / local, and use clearly-defined functions to modify them.
Reply With Quote
  #15  
Old 01-23-2008, 03:36 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
My solution was similar to some method in actionscript (I'd guess addmember). You provide the variable's name and the names of the get/set functions.

PHP Code:
function someclass() {
  
temp.var = TStaticVar();
  
with (temp.var) {
    
this.rvalue = function (obj) {
      return 
this.(@ obj);
    };
    
this.lvalue = function (obj) {
      return 
this.(@ obj).link();
    };
    
this.addmember("counter","rvalue","lvalue");
    
this.counter = -1;
  }

So depending on whether the member is the r- or lvalue, either function is called. It can be easily modified to allow for specific data types, variable protection, etc., and doesn't break backwards compatibility. The dummy/standard functions are given here.

Anyway, that's enough for derailing this thread, methinks.
__________________
◕‿‿◕ · 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
  #16  
Old 01-23-2008, 05:58 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 Novo View Post
I think the best solution for private variables is just treating them as private. The convention you use for denoting a private variable could help you.

I basically treat all variables as private / local, and use clearly-defined functions to modify them.
Yea I do it about the same way. I see private variables as more of a way of making the script idiot-proof so people other than yourself don't mess it up.
Quote:
Originally Posted by cbkbud View Post
What is thisor exactly?
Well if you used thisr. to reference private variables in the object, then what about when you're in a with (object) {} block and want to get a private variable from the calling object? Normal variables would be accessed by thiso. but you would need something thisor. for the private variables of the parent object and that is just unnecessary.
__________________
Reply With Quote
  #17  
Old 01-24-2008, 09:28 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 Inverness View Post
Normal variables would be accessed by thiso. but you would need something thisor. for the private variables of the parent object and that is just unnecessary.
This circumvents the privacy.

im in ur scope accezzin ur private variablez.
__________________
◕‿‿◕ · 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
  #18  
Old 01-25-2008, 12:46 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 Tolnaftate2004 View Post
This circumvents the privacy.

im in ur scope accezzin ur private variablez.
The original object is still executing the code, not the object in the with () block, so its not circumventing it.

I remember Stefan saying quite along time ago that something like thisr. would not be such a good idea so any argument is pointless.
__________________
Reply With Quote
  #19  
Old 01-25-2008, 03:47 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 Inverness View Post
The original object is still executing the code, not the object in the with () block, so its not circumventing it.
thisor.var = thisr.var; or thisr.var = thisor.var; in a with block would be circumventing it.

e: I think you may have misunderstood Stefan, too.
The last post wasn't meant to single you out, but after I posted, I realized how much of a pain it would have been to get my point understood.
__________________
◕‿‿◕ · 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 :/

Last edited by Tolnaftate2004; 01-25-2008 at 03:59 AM..
Reply With Quote
  #20  
Old 01-25-2008, 04:16 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
I never said anything about using thisr. in the with block, which obviously wouldn't be allowed. I think thats bad form anyhow. It would be better to use Twinny's suggestion and have the this.private. section of the object for private variables.
__________________
Reply With Quote
  #21  
Old 01-28-2008, 11:50 AM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
Quote:
Originally Posted by Inverness View Post
I never said anything about using thisr. in the with block, which obviously wouldn't be allowed. I think thats bad form anyhow. It would be better to use Twinny's suggestion and have the this.private. section of the object for private variables.
Or, like in C++ Classes, being able to define the private and public variables like so:

PHP Code:
public:
char ani;
char name[20];

private:
int health;
float xy
Reply With Quote
  #22  
Old 01-28-2008, 01:16 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
And with that, you have proven that you don't keep up with the future improvement subforum. *slaps*
Reply With Quote
  #23  
Old 01-29-2008, 12:24 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Codein View Post
Or, like in C++ Classes, being able to define the private and public variables like so:

PHP Code:
public:
char ani;
char name[20];

private:
int health;
float xy
Seems like that would kinda suck if we had to start doing int, etc.


Just like at the beginning something like

PHP Code:
private gansta;
private 
gP gangsta.newParadise();

// in another block of code

with theThing )
{
  
gP.addGangsta"Snappy Bro" );
}

// would not work 
__________________
Reply With Quote
  #24  
Old 01-29-2008, 03:48 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 cbkbud View Post
blah
You missed the point too!

http://forums.graalonline.com/forums...ad.php?t=71199
Reply With Quote
  #25  
Old 01-29-2008, 04:37 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 Twinny View Post
It seems many of us disagree with that idea.
__________________
◕‿‿◕ · 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
  #26  
Old 01-29-2008, 05:43 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Twinny View Post
Can I still do something like

PHP Code:
= new Gangsta();
gP g.newGangstasParadise(); 
... please?

EDIT:

And I really would think something like this would work
PHP Code:
private tVar n// noone can see
protected tVar n// read only
public tVar n// All rights; is this by default if nothing is said.

// even could have
static tVar n// Cannot be changed -- I thought there was a way to do this, but I can't remember it. 
__________________
Reply With Quote
  #27  
Old 01-29-2008, 08:07 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by cbkbud View Post
And I really would think something like this would work
PHP Code:
private tVar n// noone can see
protected tVar n// read only
public tVar n// All rights; is this by default if nothing is said. 
Me too . Or something similar.

Quote:
Originally Posted by cbkbud View Post
PHP Code:
// even could have
static tVar n// Cannot be changed -- I thought there was a way to do this, but I can't remember it. 
I think you can do:
PHP Code:
const tVar n
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #28  
Old 01-30-2008, 01:39 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by napo_p2p View Post
Me too . Or something similar.


I think you can do:
PHP Code:
const tVar n
Yes, something like

PHP Code:
const tVar n
sounds like what I heard. Personally I've never used it though.
__________________
Reply With Quote
  #29  
Old 02-02-2008, 01:26 PM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
Quote:
Originally Posted by cbkbud View Post
Seems like that would kinda suck if we had to start doing int, etc.
Wasn't really what I was getting at. That example I gave was C++. Using protected:, public: and private: was my idea.
Reply With Quote
  #30  
Old 02-02-2008, 02:20 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
I don't believe doing things like declaring variables private/public/protected with keywords will work in GS2.

This is because GS2 has no support for such things. const is not real value type because the compiler is merely reading it and replacing instances of it in the script with its value on compile time. After the script is compiled it no longer exists. Its about the same thing as C++'s #define.

As I said, GS2 has no support for such things for it would not be possible to do it without lots of changes that are unnecessary. That is why I suggested the Python method where variables (or functions) that have a name starting with _ are private:
PHP Code:
function onCreated() {
  
this.publicvar 5;
  
this._privatevar 7;
}
function 
_privatefunc() {
}
function 
notreallyprivatefunc() {
}
public function 
publicfunc() {

I believe thats a better option than the this.private. prefix.
__________________
Reply With Quote
  #31  
Old 02-02-2008, 03:35 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
I like this.private.foo, but maybe it could be accessed within the script with just this.foo?

The idea of _var and _func sounds really bad to me, would make code look messy in my opinion.
__________________
Reply With Quote
  #32  
Old 02-02-2008, 07:13 PM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
Quote:
Originally Posted by cbkbud View Post
I like this.private.foo, but maybe it could be accessed within the script with just this.foo?

The idea of _var and _func sounds really bad to me, would make code look messy in my opinion.
this.private seems a bit long winded. If anything, an underscore would be best. If we're talking in terms of "messy" coding as in unreadable, I'm sure a protected variable using underscores would be more noticeable than a this.protected prefix.
Reply With Quote
  #33  
Old 02-02-2008, 07:27 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 Codein View Post
this.private seems a bit long winded. If anything, an underscore would be best. If we're talking in terms of "messy" coding as in unreadable, I'm sure a protected variable using underscores would be more noticeable than a this.protected prefix.
but, underscores also mean translation if I recall ;o
PHP Code:
if (_(this.var)) 
__________________
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 07:22 AM.


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