private variables 
Author Message
 private variables

G>   "nestable local variable"

 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.

Guy Decoux



Wed, 02 Mar 2005 20:28:47 GMT  
 private variables


Quote:
> At Sat, 14 Sep 2002 07:16:14 +0900,

> > 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''.

Quote:
>   private instance variable -> noninheritable instance variable

> "private" sounds redundant and confusing, like "static" in C.

I strongly agree with you -  ``private instance variable''
is terribly  confusing - how about a
   "class local instance variable"?

/Christoph

Quote:

> -- Gotoken



Wed, 02 Mar 2005 22:25:50 GMT  
 private variables
At Sat, 14 Sep 2002 23:45:29 +0900,

Quote:

> >   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''.

I would prefer Guy's ``block local variable'' too.  
A small problem may be _var can be put at outside of block.
But really small problem.  

Quote:
> >   private instance variable -> noninheritable instance variable

> > "private" sounds redundant and confusing, like "static" in C.

> I strongly agree with you -  ``private instance variable''
> is terribly  confusing - how about a
>    "class local instance variable"?

I agree with you,  "class local -" is simpler.  

-- Gotoken



Thu, 03 Mar 2005 05:02:16 GMT  
 private variables

Quote:


>>I'd prefer having something explicit like:
>>  private_variables :some, :privvy, :vars, :listed, :here


I think this is a matter of taste, but for me a naming convention
seems to be better, since it would be simpler to tell the difference
for a particular variable.

Quote:

> I am not an expert in Ruby parser/interpreter at all (let alone computer
> science), but to me this seems perfectly doable.  I.e., after the
> detection of keyword "private_variables", all public variables in the list
> are moved from the current (public) instance variable hash to the private
> instance variable hash.  And then writing and reading the instance
> variables are like in my other post.

It would mean a slight slowdown for the access of all instance variables,
since you would need two hash lookups instead of one. If you use the naming
convention, the parser would be able to generate a node for the correct
hash lookup: you need only one (like now).

Best Regards, Christian



Fri, 04 Mar 2005 17:19:57 GMT  
 private variables

Quote:

> Actually, that raises an interesting point.

> If we're (somewhat unfortunately, imo) using '_' to denote 'localized',
> then should we be using more orthogonally?


>   _a   - localized block variable,

This is a very nice and consistent idea. I like this better than anything else:
it is convenient and easy to remeber.

I really like this.

Best Regards, Christian



Fri, 04 Mar 2005 17:23:40 GMT  
 private variables
Well, will these localized/private variables make it into the next Ruby
release?  Because there were some previous objections regarding the single
leading underscore ("I have used leading underscore in my current instance
variables"), or regarding the symmetry ("It will not look balanced"), will
there be any vote on the format of the localized variables:






Or will Matz decide on this?

Regards,

Bill
============================================================================

Quote:


>>   _a   - localized block variable,

> This is a very nice and consistent idea. I like this better than anything else:
> it is convenient and easy to remeber.
> I really like this.
> Best Regards, Christian



Fri, 04 Mar 2005 21:53:30 GMT  
 private variables
Hi --

Quote:

> Well, will these localized/private variables make it into the next Ruby
> release?  Because there were some previous objections regarding the single
> leading underscore ("I have used leading underscore in my current instance
> variables"), or regarding the symmetry ("It will not look balanced"), will
> there be any vote on the format of the localized variables:






> Or will Matz decide on this?

Ultimately Matz will decide on it, whether there's a vote or not :-)
(That's part of the "benevolent dictatorship" :-)  But still, in terms
of community consensus -- has it really come down to wanting extra
punctuation?  Isn't this one of the things (almost) everyone expresses
relief about Ruby *not* having very much of?

Personally I'd be sad to see any more double punctuation variable

true that declaring things private (rather than tagging them as
private with an underscore) means that one can't see privacy at a
glance.  But that's already true of private methods -- i.e., their
names are not required to be different from names of other methods.

David

--
David Alan Black                      | Register for RubyConf 2002!


Web:  http://pirate.shu.edu/~blackdav | http://www.rubyconf.com



Fri, 04 Mar 2005 22:28:00 GMT  
 private variables

Quote:

> Personally I'd be sad to see any more double punctuation variable

> true that declaring things private (rather than tagging them as
> private with an underscore) means that one can't see privacy at a
> glance.  But that's already true of private methods -- i.e., their
> names are not required to be different from names of other methods.

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.

Best Regards, Christian



Fri, 04 Mar 2005 22:35:42 GMT  
 private variables

d> Personally I'd be sad to see any more double punctuation variable

d> true that declaring things private (rather than tagging them as
d> private with an underscore) means that one can't see privacy at a
d> glance.  But that's already true of private methods -- i.e., their
d> names are not required to be different from names of other methods.

 In this case where do you store class local variables (i.e. what you call
 private variables :-)) ?

Guy Decoux



Fri, 04 Mar 2005 22:36:49 GMT  
 private variables
Hi --

Quote:


> d> Personally I'd be sad to see any more double punctuation variable

> d> true that declaring things private (rather than tagging them as
> d> private with an underscore) means that one can't see privacy at a
> d> glance.  But that's already true of private methods -- i.e., their
> d> names are not required to be different from names of other methods.

>  In this case where do you store class local variables (i.e. what you call
>  private variables :-)) ?

Whoops, I have reintroduced deprecated terminology into the discussion
:-) And I probably can't answer your question very cogently.  But I

In the certainty that this can't be a satisfactory answer, back to
you... :-)

David

--
David Alan Black                      | Register for RubyConf 2002!


Web:  http://pirate.shu.edu/~blackdav | http://www.rubyconf.com



Fri, 04 Mar 2005 22:48:09 GMT  
 private variables
Hi,

In message "Re: private variables"

|Well, will these localized/private variables make it into the next Ruby
|release?  Because there were some previous objections regarding the single
|leading underscore ("I have used leading underscore in my current instance
|variables"), or regarding the symmetry ("It will not look balanced"), will
|there be any vote on the format of the localized variables:
|





|
|Or will Matz decide on this?


balancing.  Those who care may put extra "__" after varriable names.

                                                        matz.



Fri, 04 Mar 2005 22:50:49 GMT  
 private variables
If you don't like underscores (because it could break

local variables?

I know, this denotes xor also, but we have a lot of
binary operators which have unary meanings (e.g.: -,*,&,%),
we just would have one more...

But all in all, underscore looks nicer and more familiar
for variable names. (Though, __variable_name__ looks very
ugly.)

Best Regards, Christian



Fri, 04 Mar 2005 22:51:37 GMT  
 private variables
Hi,

Can't we just add something like "local_iv_table" in addition to
"generic_iv_table" in variable.c?  All local variables will use something
like "rb_local_ivar_set()" and "rb_local_ivar_get()" which refers to
local_iv_table.

Regards,

Bill
=============================================================================

Quote:


>>  In this case where do you store class local variables (i.e. what you call
>>  private variables :-)) ?
> Whoops, I have reintroduced deprecated terminology into the discussion
> :-) And I probably can't answer your question very cogently.  But I
> guess I'd store them wherever they'd be stored if they were named

> In the certainty that this can't be a satisfactory answer, back to
> you... :-)



Fri, 04 Mar 2005 22:54:44 GMT  
 private variables
David:

Did you ever find out how far from the SEA airport
to the conference center and hotel?

Thanks

--
Jim Freeze
----------
Programming Ruby
 def initialize; fun; end
A language with class



Fri, 04 Mar 2005 23:02:02 GMT  
 
 [ 88 post ]  Go to page: [1] [2] [3] [4] [5] [6]

 Relevant Pages 
 

 
Powered by phpBB® Forum Software