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
  #1  
Old 03-24-2009, 10:36 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
Private variables

Support for protected and private variables would be very nice, even if only added serverside.

PHP Code:
function setVars() {
  private 
this.foo "bar";
  protected 
this.var = "str";

Other scripts could access "this.var", but not edit it. Other scripts would have absolutely no indication that "this.foo" even existed.

I'm pretty sure this has been requested before, but it still hasn't been added
__________________
Reply With Quote
  #2  
Old 05-04-2009, 05:58 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
bump
__________________
Reply With Quote
  #3  
Old 05-04-2009, 01:59 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
I agree, would be a nice addition.
Reply With Quote
  #4  
Old 05-04-2009, 03:12 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
I support this!
__________________
Reply With Quote
  #5  
Old 05-04-2009, 03:54 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 think private variables would be better implemented as some sort of prefix like __ rather than as a keyword. this.pr_blah would be private or so.

Edit: I like this.__blah__ better
__________________

Last edited by Inverness; 05-04-2009 at 04:56 PM..
Reply With Quote
  #6  
Old 05-04-2009, 03:57 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
Good idea, I totally support.

Quote:
Originally Posted by Inverness View Post
I think private variables would be better implemented as some sort of prefix like __ rather than as a keyword. this.pr_blah would be private or so.
Why?
Reply With Quote
  #7  
Old 05-04-2009, 04:10 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
I think they would fit good as keywords, such as const
__________________
Reply With Quote
  #8  
Old 05-04-2009, 04:16 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 Chompy View Post
I think they would fit good as keywords, such as const
I agree
Reply With Quote
  #9  
Old 05-04-2009, 04:52 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 Codein View Post
Why?
Graal is highly dynamic language, I don't think it's a good idea to have private variables unless there is easy to tell the access level of any variable.
Quote:
Originally Posted by Chompy View Post
I think they would fit good as keywords, such as const
const is not part of GScript itself, they are resolved by the compiler, similar to a macro in C.

Making changes to a language syntax is something that requires alot of thought, and I'm annoyed with the lack of it right now.
__________________
Reply With Quote
  #10  
Old 05-04-2009, 05:03 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 Inverness View Post
Graal is highly dynamic language, I don't think it's a good idea to have private variables unless there is easy to tell the access level of any variable.
Hrm, I can see what you mean. However, I don't agree that the 'pr_' prefix is the best way to DECLARE a private variable.

Maybe something like this:

PHP Code:
private this.pr_var "redfish"
Where the keyword actually declares the variable as private, and the name indicates that it is a private variable, as some sort of convention maybe.

I think indicating what's private and what's not should be completely down to the programmer.
Reply With Quote
  #11  
Old 05-04-2009, 05:17 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 Codein View Post
Hrm, I can see what you mean. However, I don't agree that the 'pr_' prefix is the best way to DECLARE a private variable.

Maybe something like this:

PHP Code:
private this.pr_var "redfish"
Where the keyword actually declares the variable as private, and the name indicates that it is a private variable, as some sort of convention maybe.

I think indicating what's private and what's not should be completely down to the programmer.
I am 100 percent against a private keyword. Graal is too dynamic to have variable behavior changed by keywords.

I think this.__var (or this.__var__) is a much better way of indicating a private variable, because you can simply look at it and know that it's private without having to use a function to check the access level.

A great many scripters on Graal don't understand the importance of convention in a scripting language and Stefan makes no effort to try to enforce one. So even if you propose a convention it will most likely not be upheld and everyone will just indicate private variables however they please. My proposition forces scripters to name the variable a specific way if they want the functionality. You're defeating yourself with your own argument's complexity, simple is better.

Edit: Also, isn't it rather redundant to have both the keyword and the convention? If you're wanting everyone to use pr_ to indicate private variables, why not simply make that the way to declare them? That way you don't need to make a more complicated change to GScript by introducing access level keywords.
Quote:
Originally Posted by Loriel View Post
I do not see what being dynamic has to do with anything. In Ruby, which is dynamic as ****, every member variable is private.
Well if every member variable is private you don't need a private keyword then.
Quote:
Originally Posted by Loriel View Post
By that logic, C has no language features since they are all resolved by the compiler to assembly.
I'm saying that const is a compiler feature, not really a feature of GScript. With the proposed access level keyword, that would not be the case. So you can't say private would fit good with keywords such as const, because const isn't part of GScript, and an access level constraint certainly is.

Edit2: I just noticed I reached 3,000 posts, yay me.
__________________

Last edited by Inverness; 05-04-2009 at 05:32 PM..
Reply With Quote
  #12  
Old 05-04-2009, 05:53 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 Inverness View Post
I am 100 percent against a private keyword. Graal is too dynamic to have variable behavior changed by keywords.

I think this.__var (or this.__var__) is a much better way of indicating a private variable, because you can simply look at it and know that it's private without having to use a function to check the access level.

A great many scripters on Graal don't understand the importance of convention in a scripting language and Stefan makes no effort to try to enforce one. So even if you propose a convention it will most likely not be upheld and everyone will just indicate private variables however they please. My proposition forces scripters to name the variable a specific way if they want the functionality.

Edit: Also, isn't it rather redundant to have both the keyword and the convention? If you're wanting everyone to use pr_ to indicate private variables, why not simply make that the way to declare them? That way you don't need to make a more complicated change to GScript by introducing access level keywords.
Yeah, I can see exactly what you mean. However, I still think a keyword would still be best. I mean, I have, for some time, wanted some kind of support for classes, in a traditional sense and keywords for declaring class members would be necessary in my opinion.

Also, I don't see you preaching conventions, being in a position of influence within the scripting community. If you shown the importance of them, like many other of the Scripting Elite on here, there should be an improvement in that field.

Regarding your edit, the convention is optional, as with any convention. It's just recommended. There's something about using what LOOKS like a convention as an actual declaration gets to me, for some reason.

However, I'd just like to see private variables. If Stefan agrees with you, I'm not really bothered, as such. It still does what I want.
Reply With Quote
  #13  
Old 05-04-2009, 05:16 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Quote:
Originally Posted by Inverness View Post
Graal is highly dynamic language, I don't think it's a good idea to have private variables unless there is easy to tell the access level of any variable.
I do not see what being dynamic has to do with anything. In Ruby, which is dynamic as ****, every member variable is private.

Quote:
const is not part of GScript itself, they are resolved by the compiler, similar to a macro in C.
By that logic, C has no language features since they are all resolved by the compiler to assembly.

Quote:
Making changes to a language syntax is something that requires alot of thought, and I'm annoyed with the lack of it right now.
Just give us Scheme macros so we do not have to bug Stefan to change the syntax for us.
Reply With Quote
  #14  
Old 05-04-2009, 04:19 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Quote:
Originally Posted by cbk1994 View Post
Other scripts would have absolutely no indication that "this.foo" even existed.
What would happen if some other script tried to set it?
Reply With Quote
  #15  
Old 05-04-2009, 08:24 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
Taking into account the way variables are serialised, I think your way would be the better way to implement, yeah.

Last edited by Codein; 05-04-2009 at 08:52 PM..
Reply With Quote
  #16  
Old 05-05-2009, 12:14 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
From my thread on this, http://forums.graalonline.com/forums...ad.php?t=71199

Stefan originally suggested the possibility of thisr. or this.protected.whatevs
Reply With Quote
  #17  
Old 05-05-2009, 03:45 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
From my thread on this, http://forums.graalonline.com/forums...ad.php?t=71199

Stefan originally suggested the possibility of thisr. or this.protected.whatevs
I think it is better to have the indicator in the variable name because of the reasons I mentioned above, imho. thisr. isn't really part of the variable name.
__________________
Reply With Quote
  #18  
Old 05-17-2009, 02:23 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
bump
__________________
Reply With Quote
  #19  
Old 06-18-2009, 03:37 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
bump
__________________
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 09:31 PM.


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