On Mon, Sep 16, 2002 at 11:50:54PM +0900, Christian Szegedy wrote:
Private methods and class-local instance variables are quite different.
If you use a private method, you get an exception. If you try to use
a class-local instance variable then you just use another variable,
which could lead to obscure bugs.
So I think punctuation (and it should be as short as possible)
is a much better option.
If you try to use a class-local instance variable and it has not yet
been initialized, I would expect to see a warning when you run with ruby
-w, just like you get now with regular instance variables.
Paul
I often initialize instance variables conditionally. (That is, on first use).
so were talking about instance variables being private? ugh, i’m
confused (sorry i didn’t catch the whole of this thread) arn’t instance
variable always private? you can only access them through accessor
methods. i’m missing somthing here.
They are object private, but not class private. (Puritans and C++
programmers would say they are “protected”, since the subclass can reach
them.)
···
–
([ Kent Dahl ]/)_ ~[ http://www.stud.ntnu.no/~kentda/ ]/~
))_student/(( _d L b_/ NTNU - graduate engineering - 5. year )
( __õ|õ// ) )Industrial economics and technological management(
_/ö____/ (_engineering.discipline=Computer::Technology)
I think you are right that “%X” sometimes is already special in Ruby (such
as %q, %Q, %w, %r, and %x). However, the use of “#” is really scary,
because it will make most, if not all, comments break down.
Oh, I know – I wouldn’t really advocate it. Actually I’m keeping my
fingers crossed that Ruby never gets any more punctuation prefixes on
variable names at all.
Hmmm, time to search other Perl symbols… how about "", anyone? Has
this symbol been used in Ruby?
Well, they don’t have to be “Perl symbols” specifically… but I hope
the point will turn out to be moot anyway
David
···
On Sat, 14 Sep 2002, William Djaja Tjokroaminata wrote:
I’m not going to choose attr_private (unless someone put some idea in
my brain), because
a) we need static information about class local instance variable at
compile time. Dynamic attr_priate at run time is too late.
b) if we choose attr_private (by making it a syntax), we need to
search for declaration to distinguish whether a instance variable
is class local or not. I don’t feel it’s a Ruby Way ™.
matz.
···
In message “Re: private variables” on 02/09/17, James F.Hranicky jfh@cise.ufl.edu writes:
Please note that the destination address is approximate. It’s an
intersection near the convention center. Any taxi will know it by name.
A taxi will be your most expensive option (about $40-$50???) but is
readily available outside baggage claim.
Also, there is also the 194 bus that runs very frequently and during
the weekday goes through the city’s bus tunnel. The last stop going
north puts you at the Convention Center stop. It’s also the last stop
in the tunnel. Cost: $1.25-$2.50. Check http://transit.metrokc.gov/bus/flymetro.html for exact details.
Finally (out of my reccomendations), there is shuttle express, which
you can get to by going to the parking garage outside the Sea-Tac
airport and going to the 3rd level. There should be signs for it. They
cost $22 door-to-door, run very very often any hour of the day, and (at
least going TO the airport) the second person is free. So gang up w/ a
fellow rubiest and split the cost!
···
On Monday, September 16, 2002, at 07:50 AM, Jim Freeze wrote:
Did you ever find out how far from the SEA airport
to the conference center and hotel?
Wait, wait, wait… I think someone should really have defined what
private variables in Ruby really are.
Using C++ terminology, I think the private variables in Ruby are really
like C++ “private” variables. In the current Ruby, instance variables are
always “protected”, and they can only be made “public” by the accessor
functions.
Regards,
Bill
···
============================================================================
Kent Dahl kentda@stud.ntnu.no wrote:
Tom Sawyer wrote:
so were talking about instance variables being private? ugh, i’m
confused (sorry i didn’t catch the whole of this thread) arn’t instance
variable always private? you can only access them through accessor
methods. i’m missing somthing here.
They are object private, but not class private. (Puritans and C++
programmers would say they are “protected”, since the subclass can reach
them.)
a private instance variable is one that is not inheritable. is that the
only difference?
using _@, or anyhting like that is pretty ugly. it would also make me
want to use _ in front of all my local variables, which take me back to
my old idea of using % for regular locals: then all variables would have
a puncutation mark in front of them.
$ - global
@@ - class
@ - instance
%@ - local instance
% - local
but % smacks of code breakage, unless it were optional.
what about using parentheticals instead? since currently it is pointless
to write: (@local). this may be a better notation.
just a thought.
-tom
···
On Mon, 2002-09-16 at 10:51, Yukihiro Matsumoto wrote:
Hi,
In message “Re: private variables” > on 02/09/17, James F.Hranicky jfh@cise.ufl.edu writes:
Are we dead set against “attr_private” ?
class Foo
attr_private :bar
end
?
I’m not going to choose attr_private (unless someone put some idea in
my brain), because
a) we need static information about class local instance variable at
compile time. Dynamic attr_priate at run time is too late.
b) if we choose attr_private (by making it a syntax), we need to
search for declaration to distinguish whether a instance variable
is class local or not. I don’t feel it’s a Ruby Way ™.
I’m not going to choose attr_private (unless someone put some idea in
my brain), because
a) we need static information about class local instance variable at
compile time. Dynamic attr_priate at run time is too late.
b) if we choose attr_private (by making it a syntax), we need to
search for declaration to distinguish whether a instance variable
is class local or not. I don’t feel it’s a Ruby Way ™.
Hrm, this thread has been so huge that I’ve been in skim mode. I
understand that attr_private wouldn’t work because its dynamic and
determined at runtime, but I’m wondering if there isn’t another single
character that could be used in the grammar to designate a private
instance variable. I couldn’t think of any without there being some
kind of compile time declaration of a symbol… but there doesn’t
seem like there’s any way of providing compile time hints outside of
the special characters that get prepended to a symbol name. Just a
thought, but would it be possible to introduce a compile time syntax
for providing hints to the compiler? If so, then that’d likely open
up possibilities for other naming schemes. ::shrug:: Just my $0.02.
-sc
Maybe the subject “private variable” is confusing. In Ruby, the
concept of “private” means “cannot be omitted its receiver”. But
there doesn’t exist receiver of a variable. In this sense, variable
is already “private”.
So, I’d like to propose new name
“nestable local variable” and “noninheritable instance variable”
to avoid confusion.
– Gotoken
···
At Sat, 14 Sep 2002 06:22:55 +0900, William Djaja Tjokroaminata wrote:
Wait, wait, wait… I think someone should really have defined what
private variables in Ruby really are.
Using C++ terminology, I think the private variables in Ruby are really
like C++ “private” variables. In the current Ruby, instance variables are
always “protected”, and they can only be made “public” by the accessor
functions.
I think Matz is already deciding between “@_xxx” and “@__xxx”.
Regards,
Bill
···
==========================================================================
Sean Chittenden sean@chittenden.org wrote:
(deleted)
instance variable. I couldn’t think of any without there being some
kind of compile time declaration of a symbol… but there doesn’t
seem like there’s any way of providing compile time hints outside of
the special characters that get prepended to a symbol name. Just a
thought, but would it be possible to introduce a compile time syntax
for providing hints to the compiler? If so, then that’d likely open
up possibilities for other naming schemes. ::shrug:: Just my $0.02.
-sc
what do you mean by nested local variable? is that suppose to be the
same thing as noninheritable instance variable? or are you refering the
other kind of “private” variables ruby already has?
···
On Fri, 2002-09-13 at 16:04, GOTO Kentaro wrote:
At Sat, 14 Sep 2002 06:22:55 +0900, > William Djaja Tjokroaminata wrote:
Wait, wait, wait… I think someone should really have defined what
private variables in Ruby really are.
Using C++ terminology, I think the private variables in Ruby are really
like C++ “private” variables. In the current Ruby, instance variables are
always “protected”, and they can only be made “public” by the accessor
functions.
Maybe the subject “private variable” is confusing. In Ruby, the
concept of “private” means “cannot be omitted its receiver”. But
there doesn’t exist receiver of a variable. In this sense, variable
is already “private”.
So, I’d like to propose new name
“nestable local variable” and “noninheritable instance variable”
to avoid confusion.
Well, personnaly I'll call it "block local variable". For this reason
pigeon% ruby -e '_a = 12; 1.times { puts _a }'
-e:1: undefined local variable or method `_a' for #<Object:0x401bda4c> (NameError)
from -e:1:in `times'
from -e:1
pigeon%
The reason is that you can cut/paste the block and you have always the
same result : if the variable was assigned in the block ruby find it,
otherwise it try to call the method.
I meant change name. Not introducing other kind of variable.
private local variable → nestable local variable
private instance variable → noninheritable instance variable
“private” sounds redundant and confusing, like “static” in C.
– Gotoken
···
At Sat, 14 Sep 2002 07:16:14 +0900, Tom Sawyer wrote:
what do you mean by nested local variable? is that suppose to be the
same thing as noninheritable instance variable? or are you refering the
other kind of “private” variables ruby already has?
what do you mean by nested local variable? is that suppose to be the
same thing as noninheritable instance variable? or are you refering the
other kind of “private” variables ruby already has?
I meant change name. Not introducing other kind of variable.
private local variable → nestable local variable
I tend to agree with Guy - block local variable'' is a more descriptive name for me. In fact, I probably would identify nestable local variable’’ to be the exact opposite of a
``block local variable’'.