Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
how private is private in ruby?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  11 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Peter Ertl  
View profile  
 More options Oct 26 2005, 3:32 pm
Newsgroups: comp.lang.ruby
From: "Peter Ertl" <pe...@gmx.org>
Date: Thu, 27 Oct 2005 04:32:36 +0900
Local: Wed, Oct 26 2005 3:32 pm
Subject: how private is private in ruby?
Why is this allowed / possible?

class MyUltraSecretKeystore
  private
  def key
    return "nobody-should-read-this-ever"
  end
end

ks = MyUltraSecretKeystore.new

$ puts ks.send(:key)

> "nobody-should-read-this-ever"

*yuk*

so I can just use [public] for _everything_ as well, right?

Best regards
Peter


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Edward Gray II  
View profile  
 More options Oct 26 2005, 3:38 pm
Newsgroups: comp.lang.ruby
From: James Edward Gray II <ja...@grayproductions.net>
Date: Thu, 27 Oct 2005 04:38:36 +0900
Local: Wed, Oct 26 2005 3:38 pm
Subject: Re: how private is private in ruby?
On Oct 26, 2005, at 2:32 PM, Peter Ertl wrote:

It's true that there are many ways to bypass method scope.  Ruby  
trusts us to do the right thing. We consider things like send() and  
instance_eval() to be tools.  They are perhaps dangerous at times,  
but they are also very powerful.  It's a trade-off.

If you're looking for iron-clad laws, Ruby's dynamic nature will  
probably not appeal to you much.

James Edward Gray II


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Edward Faulkner  
View profile  
 More options Oct 26 2005, 3:45 pm
Newsgroups: comp.lang.ruby
From: Edward Faulkner <e...@alum.mit.edu>
Date: Thu, 27 Oct 2005 04:45:40 +0900
Local: Wed, Oct 26 2005 3:45 pm
Subject: Re: how private is private in ruby?

On Thu, Oct 27, 2005 at 04:32:36AM +0900, Peter Ertl wrote:
> Why is this allowed / possible?
> $ puts ks.send(:key)

> so I can just use [public] for _everything_ as well, right?

While it may or may not be a good idea that #send subverts access
control, your choice of example betrays a misunderstanding of the
meaning of "private".

"private" is not intended as a security measure.  It's an
encapsulation technique.  You'll find this is generally true in other
languages as well.  You can certainly subvert "private" in C++.

"private" exists only to tell other programmers which methods they
really shouldn't be calling.  

regards,
Ed

  signature.asc
< 1K Download

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Ertl  
View profile  
 More options Oct 26 2005, 3:47 pm
Newsgroups: comp.lang.ruby
From: "Peter Ertl" <pe...@gmx.org>
Date: Thu, 27 Oct 2005 04:47:48 +0900
Local: Wed, Oct 26 2005 3:47 pm
Subject: Re: how private is private in ruby?
not a big deal.. i pretty much enjoy the freedom of ruby!

I have years of java type safety and design pattern torture
behind me and ruby is the light at the end of the tunnel :-)

however, wouldn't it make sense to forbid Object#send
when using a specific taint level?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David A. Black  
View profile  
 More options Oct 26 2005, 3:50 pm
Newsgroups: comp.lang.ruby
From: "David A. Black" <dbl...@wobblini.net>
Date: Thu, 27 Oct 2005 04:50:32 +0900
Local: Wed, Oct 26 2005 3:50 pm
Subject: Re: how private is private in ruby?
Hi --

On Thu, 27 Oct 2005, Peter Ertl wrote:
> not a big deal.. i pretty much enjoy the freedom of ruby!

> I have years of java type safety and design pattern torture
> behind me and ruby is the light at the end of the tunnel :-)

> however, wouldn't it make sense to forbid Object#send
> when using a specific taint level?

There was a fairly huge thread not long ago on the matter of having
two versions of 'send', one of which would include private methods and
the other of which wouldn't.  I don't think anything was decided,
except that Matz didn't like my idea of 'send' vs. 'send!' :-)

David

--
David A. Black
dbl...@wobblini.net


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
rubyhac...@gmail.com  
View profile  
 More options Oct 26 2005, 4:06 pm
Newsgroups: comp.lang.ruby
From: rubyhac...@gmail.com
Date: 26 Oct 2005 13:06:18 -0700
Local: Wed, Oct 26 2005 4:06 pm
Subject: Re: how private is private in ruby?

Edward Faulkner wrote:

> While it may or may not be a good idea that #send subverts access
> control, your choice of example betrays a misunderstanding of the
> meaning of "private".

> "private" is not intended as a security measure.  It's an
> encapsulation technique.  You'll find this is generally true in other
> languages as well.  You can certainly subvert "private" in C++.

> "private" exists only to tell other programmers which methods they
> really shouldn't be calling.

Exactly right.

I made an analogy the other day with the movie _Apollo 13_. Remember
when Bacon's character had been awake for many hours and was, as he
said, "a little punchy"? There was a toggle switch which would
separate the two modules (and thus doom to death the other two astro-
nauts who were spending their time in the other one). He taped a
piece of paper over it saying "NO."

That's how "private" works.

Hal


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremy Kemper  
View profile  
 More options Oct 26 2005, 4:01 pm
Newsgroups: comp.lang.ruby
From: Jeremy Kemper <jer...@bitsweat.net>
Date: Thu, 27 Oct 2005 05:01:25 +0900
Local: Wed, Oct 26 2005 4:01 pm
Subject: Re: how private is private in ruby?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Oct 26, 2005, at 12:32 PM, Peter Ertl wrote:

In current Ruby 1.9 you may not send private methods.  I don't know
whether this is an experiment or a permanent restriction.

Regardless, you may ks.instance_eval { key } anyway, though in
this case at least you have $SAFE at your disposal.

jeremy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (Darwin)

iD8DBQFDX+CVAQHALep9HFYRAlV3AJ9BEHcb5Xmb8qRLS09A8KXJCIU4sQCfQroC
k0r75fKUoI5Z3UiE0upzDc8=
=X4SS
-----END PGP SIGNATURE-----


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tanner Burson  
View profile  
 More options Oct 26 2005, 4:30 pm
Newsgroups: comp.lang.ruby
From: Tanner Burson <tanner.bur...@gmail.com>
Date: Thu, 27 Oct 2005 05:30:58 +0900
Local: Wed, Oct 26 2005 4:30 pm
Subject: Re: how private is private in ruby?

On 10/26/05, rubyhac...@gmail.com <rubyhac...@gmail.com> wrote:

That has got to be one of the best analogies I've read in a long, long time

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin DeMello  
View profile  
 More options Oct 26 2005, 4:37 pm
Newsgroups: comp.lang.ruby
From: Martin DeMello <martindeme...@yahoo.com>
Date: Wed, 26 Oct 2005 20:37:33 GMT
Local: Wed, Oct 26 2005 4:37 pm
Subject: Re: how private is private in ruby?

Tanner Burson <tanner.bur...@gmail.com> wrote:
> On 10/26/05, rubyhac...@gmail.com <rubyhac...@gmail.com> wrote:

> > I made an analogy the other day with the movie _Apollo 13_. Remember
> > when Bacon's character had been awake for many hours and was, as he
> > said, "a little punchy"? There was a toggle switch which would
> > separate the two modules (and thus doom to death the other two astro-
> > nauts who were spending their time in the other one). He taped a
> > piece of paper over it saying "NO."

> > That's how "private" works.

> That has got to be one of the best analogies I've read in a long, long time

Agreed! Though there goes our "come on, it's not exactly rocket science"
argument :)

martin


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gene Tani  
View profile  
 More options Oct 26 2005, 4:41 pm
Newsgroups: comp.lang.ruby
From: "Gene Tani" <gene.t...@gmail.com>
Date: 26 Oct 2005 13:41:09 -0700
Local: Wed, Oct 26 2005 4:41 pm
Subject: Re: how private is private in ruby?
the other way to subvert private (or protected) declarations is to
subclass the class with the private methods, and declare the
superclass' private method public in the subclass.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David A. Black  
View profile  
 More options Oct 26 2005, 5:19 pm
Newsgroups: comp.lang.ruby
From: "David A. Black" <dbl...@wobblini.net>
Date: Thu, 27 Oct 2005 06:19:57 +0900
Local: Wed, Oct 26 2005 5:19 pm
Subject: Re: how private is private in ruby?
Hi --

On Thu, 27 Oct 2005, Gene Tani wrote:
> the other way to subvert private (or protected) declarations is to
> subclass the class with the private methods, and declare the
> superclass' private method public in the subclass.

I don't think that has any effect.  You could, however, reopen the
class itself and (re)declare the methods public.

David

--
David A. Black
dbl...@wobblini.net


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google