[#4654] signleton_methods / methods / public_methods - weirdness? — Johan Holmberg <holmberg@...>
[#4666] Getting a hex representation for a Numeric — "Zev Blut" <rubyzbibd@...>
Hello,
[#4670] ruby 1.8.3 preview1 plan — Yukihiro Matsumoto <matz@...>
Hi,
[#4690] test failures for stable-snapshot 09/04/2005 — noreply@...
Bugs item #1762, was opened at 10-04-2005 20:46
Hello.
[#4709] BNF-like grammar specified DIRECTLY in Ruby — Eric Mahurin <eric_mahurin@...>
Hello everybody,
[#4712] Segfault in zlib? — Nathaniel Talbott <ntalbott@...>
I'm using rubyzip (latest gem version) and zlib (1.2.2) to do a bunch
[#4736] Trivial speedup in Array#zip — Mauricio Fern疣dez <batsman.geo@...>
[#4745] Win32: Ruby & APR; build problems for Ruby Subversion SWIG bindings — Erik Huelsmann <ehuels@...>
Having taken upon me the task to provide a Windows build for
On 4/20/05, Erik Huelsmann <ehuels@gmail.com> wrote:
Hi Austin,
Hi,
On 4/24/05, nobu.nokada@softhome.net <nobu.nokada@softhome.net> wrote:
Hi,
> > > Ruby is just using AC_TYPE_UID_T. So, using typedef for them,
Hi,
On 4/26/05, nobu.nokada@softhome.net <nobu.nokada@softhome.net> wrote:
As promised, I attached a patch to eliminate the compile problems
Hi,
Thanks for the quick response!
Hi,
On 5/14/05, nobu.nokada@softhome.net <nobu.nokada@softhome.net> wrote:
[#4751] Illegal regexp causes segfault — Andrew Walrond <andrew@...>
irb(main):058:0> a = /\[([^]]*)\]/
Andrew Walrond, April 22:
In article <200504221210.38231.andrew@walrond.org>,
>>>>> "T" == Tanaka Akira <akr@m17n.org> writes:
[#4774] enhanced $0 modification — Evan Webb <evanwebb@...>
The attached patch allows for ruby to use more of the available stack
Hi,
[#4775] profiler.rb Schroedinbug — C Erler <erlercw@...>
A ruby program with the single instruction "require 'profile'"
>A ruby program with the single instruction "require 'profile'"
[#4807] Re: -Wall — Vincent Isambart <vincent.isambart@...>
> Why does ruby build without -Wall in CFLAGS by default? -Wall can help to
[#4815] Re: -Wall — nobu.nokada@...
Hi,
Re: return_value? [Was: Re: want_object? - possible?]
On 4/15/05, David A. Black <dblack@wobblini.net> wrote:
> On Sat, 16 Apr 2005, Mark Hubbart wrote:
>
> > On 4/15/05, Eric Hodel <drbrain@segment7.net> wrote:
> >> On 14 Apr 2005, at 22:20, Mark Hubbart wrote:
> >>>
> >>> The example above, while being very funny, is nothing like what's
> >>> being suggested:
> >>> - it's a custom method grabbing absurdly specific external context
> >>> information
> >>> - it's using the requested information to do something entirely silly
> >>> in it own right
> >>> By using this example, it appears that you are trying to say that it's
> >>> a slippery slope; from a method telling you whether a return value is
> >>> in a position to be used, to a specialized method call which tells you
> >>> whether a specific method of a certain class will be called on the
> >>> result.
> >>
> >> I think the (snipped) example was highly illustrative.
> >
> > Maybe I'm wrong. The code seemed intended to be ridiculous, a parody
> > of "what might happen". I mean really, "subsequently_flattened?"? But
> > I suppose I might have misjudged.
>
> It's more an example of what would have happened, already, with a
> #return_value_used? method -- namely, there would be leakage of
> knowledge about the next method call into this method call, which I
> think is bad. Having a facility that tells you whether you are being
> succeeded by a call to #flatten is just a minor variant of having a
> facility that tells you whether you are being succeeded by another
> method call at all. I used that example, not to warn of unreasonable
> uses that might lie beyond a reasonable use, but to bring into sharper
> relief the problems that inhere in the whole thing in any form.
Okay, I misunderstood then. Still, I don't think they are in the same
category. I see a big difference between the question "should I bother
returning a value?" (or more precisely, "will there be any references
to my returned value after this method call?") and "what will be in
the future for my returned value?". Using it for anything other than
deciding whether to return a value would be looked down on. It should
be *only* for optimization purposes, not to change states.
The way I perceived it, the method would not be about whether there
will be a subsequent method call. It's about whether the value will be
stored or used. So return_value? inside the method do_something would
be true in these cases:
do_something.do_something_else
puts do_something
f = do_something
but not in this case:
do_something # return value is ignored.
This code:
def foo
if return_value?
STDERR.puts "returning value"
23
else
STDERR.puts "not returning a value"
end
end
foo
num = foo
puts num
puts foo
would print:
not returning a value
returning a value
23
returning a value
23
There are other features in Ruby that could be horribly abused, but
they usually aren't, in production code anyway. Also, as far as this
method goes, I don't see much potential for using it as a dirty hack
for anything.
I just realized that this could conceivably be useful in things like
drb, where you might end up sending a huge marshalled object across
the network as a return value. If it's not going to be used, why
return it over the network, simply to be discarded?
As for the lookahead aspect of it, you could alternatively look at
this this as more of an immediate lazy evaluation; instead of
computation of values being delayed in case it's not needed, it would
be computed immediately, but only if it was needed.
cheers,
Mark