From: Peter Date: 2012-08-15T11:42:32+09:00 Subject: Re: Idea: def ... end returns the symbolized version of the newly-defined method, instead of nil --14dae9340ed9b0e68404c744e066 Content-Type: text/plain; charset=ISO-8859-1 Forgot: > Esp if you've ever gotten used to reading idiomatic java I have never had to get used to Java on my way to Ruby and I consider that a perk. AND an achievement. :) On Tue, Aug 14, 2012 at 10:41 PM, Peter wrote: > Not sure if you've ever worked on large classes in large Ruby/Rails > projects (unless you want to count "possible code smell" as an argument > against this, putting that aside for a moment) but if a "protected" or > "private" block is fairly large, it gets difficult to see what's going on > without doing "private :method_just_defined_on_previous_line" dozens of > times (which to me is a different kind of smell, but some consider it a > valid style). > > Since a symbol is already created when a method is defined, and we are > dealing with a functional language (or one with functional aspects), I just > think it would be useful for a def to return something other than "nil", > and it would nicely dovetail with the fact that "protected" and "private" > can take symbol arguments. There are no extra costs involved. > > > Personally, I've never found protected/private to be useful. > > Your anecdotal experience does not count as evidence towards utility. > > > Do note that your proposed "syntax" above is mostly achieved with 2 > chars added: > > No, actually that only works for the case of 2 methods, one protected and > one private. If you have 10 protected methods and 10 private methods, the > situation quickly becomes more complicated. > > -Peter > > On Mon, Aug 13, 2012 at 9:17 PM, Ryan Davis wrote: > >> >> On Aug 13, 2012, at 12:59 , Peter wrote: >> >> > This would allow useful syntax constructs such as this: >> > >> > protected def protected_method >> > ... >> > end >> > >> > and >> > >> > private def private_method >> > ... >> > end >> >> Personally, I've never found protected/private to be useful. Do note that >> your proposed "syntax" above is mostly achieved with 2 chars added: >> >> protected; def protected_method >> ... >> end >> >> and >> >> private; def private_method >> ... >> end >> >> and so I really don't see the point. Esp if you've ever gotten used to >> reading idiomatic java, then the newline looks fine: >> >> protected >> def protected_method >> ... >> end >> >> and >> >> private >> def private_method >> ... >> end >> >> >> > > > -- > "I'd put my money on the sun and solar energy. What a source of power! I > hope we don't have to wait until oil and coal run out before we tackle > that." > -Thomas Edison, 1931 > -- "I'd put my money on the sun and solar energy. What a source of power! I hope we don't have to wait until oil and coal run out before we tackle that." -Thomas Edison, 1931 --14dae9340ed9b0e68404c744e066 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Forgot:

>=A0Es= p if you've ever gotten used to reading idiomatic java

I have never had to get us= ed to Java on my way to Ruby and I consider that a perk. AND an achievement= . :)

On Tue, Aug 14, 2012 at 10:41 PM, Pet= er <lumbergh@gmail.com> wrote:
Not sure if you've ever worked on large classes in large Ruby/Rails pro= jects (unless you want to count "possible code smell" as an argum= ent against this, putting that aside for a moment) but if a "protected= " or "private" block is fairly large, it gets difficult to s= ee what's going on without doing "private :method_just_defined_on_= previous_line" dozens of times (which to me is a different kind of sme= ll, but some consider it a valid style).

Since a symbol is already created when a method is defined, = and we are dealing with a functional language (or one with functional aspec= ts), I just think it would be useful for a def to return something other th= an "nil", and it would nicely dovetail with the fact that "p= rotected" and "private" can take symbol arguments. There are= no extra costs involved.

>=A0Personally, I've never found protected/= private to be useful.

Your anecdotal experience does not count as evidence towards utility.

>=A0Do note that your proposed "syntax" above = is mostly achieved with 2 chars added:

No, actually th= at only works for the case of 2 methods, one protected and one private. If = you have 10 protected methods and 10 private methods, the situation quickly= becomes more complicated.

-Peter

On Mon, Aug 13, 2012 at 9:17 PM, Ryan Davis = <ryand-ruby@zenspider.com> wrote:

On Aug 13, 2012, at 12:59 , Peter <lumbergh@gmail.com> wrote:

> This would allow useful syntax constructs such as this:
>
> protected def protected_method
> =A0 ...
> end
>
> and
>
> private def private_method
> =A0 ...
> end

Personally, I've never found protected/private to be useful. Do n= ote that your proposed "syntax" above is mostly achieved with 2 c= hars added:

=A0 =A0 =A0 =A0 protected; def protected_method
=A0 =A0 =A0 =A0 =A0 ...
=A0 =A0 =A0 =A0 end

=A0 =A0 =A0 =A0 and

=A0 =A0 =A0 =A0 private; def private_method
=A0 =A0 =A0 =A0 =A0 ...
=A0 =A0 =A0 =A0 end

and so I really don't see the point. Esp if you've ever gotte= n used to reading idiomatic java, then the newline looks fine:

=A0 =A0 =A0 =A0 protected
=A0 =A0 =A0 =A0 def protected_method
=A0 =A0 =A0 =A0 =A0 ...
=A0 =A0 =A0 =A0 end

=A0 =A0 =A0 =A0 and

=A0 =A0 =A0 =A0 private
=A0 =A0 =A0 =A0 def private_method
=A0 =A0 =A0 =A0 =A0 ...
=A0 =A0 =A0 =A0 end





<= /div>
--
"I'd put my money on the sun and sol= ar energy. What a source of power! I hope we don't have to wait until o= il and coal run out before we tackle that."
-Thomas Edison, 1931



--
"I'= d put my money on the sun and solar energy. What a source of power! I hope = we don't have to wait until oil and coal run out before we tackle that.= "
-Thomas Edison, 1931
--14dae9340ed9b0e68404c744e066--