[#4341] DRY and embedded docs. — Hugh Sasse Staff Elec Eng <hgs@...>
If I have a here document in some ruby program:
[#4347] Re: DATA and rewind. — ts <decoux@...>
>>>>> "H" == Hugh Sasse Staff Elec Eng <hgs@dmu.ac.uk> writes:
[#4350] Re: Thirty-seven Reasons [Hal Fulton] Love[s] Ruby — "David Douthitt" <DDouthitt@...>
[#4396] Re: New Require (was: RAA development ideas (was: RE: Looking for inp ut on a 'links' page)) — Hugh Sasse Staff Elec Eng <hgs@...>
On 9 Aug 2000, Dave Thomas wrote:
[#4411] Re: RAA development ideas (was: RE: Lookin g for inp ut on a 'links' page) — Aleksi Niemel<aleksi.niemela@...>
Me:
On Thu, 10 Aug 2000, [iso-8859-1] Aleksi Niemelwrote:
[#4465] More RubyUnit questions. — Hugh Sasse Staff Elec Eng <hgs@...>
I am beginning to get a feel for this, but I still have a few more
[#4478] Re: RubyUnit. Warnings to be expected? — ts <decoux@...>
>>>>> "H" == Hugh Sasse Staff Elec Eng <hgs@dmu.ac.uk> writes:
[#4481] Invoking an extension after compilation — Dave Thomas <Dave@...>
Hi,
[#4501] What's the biggest Ruby development? — Dave Thomas <Dave@...>
[#4502] methods w/ ! giving nil — Hugh Sasse Staff Elec Eng <hgs@...>
I have got used to the idea that methods that end in '!' return nil if
[#4503] RubyUnit and encapsulation. — Hugh Sasse Staff Elec Eng <hgs@...>
My_class's instance variables are not all "attr :<name>" type variables,
[#4537] Process.wait bug + fix — Brian Fundakowski Feldman <green@...>
If your system uses the rb_waitpid() codepath of rb_f_wait(),
[#4567] Re: What's the biggest Ruby development? — Aleksi Niemel<aleksi.niemela@...>
Dave said:
Robert Feldt <feldt@ce.chalmers.se> writes:
On Sat, 26 Aug 2000, Dave Thomas wrote:
Robert Feldt <feldt@ce.chalmers.se> writes:
On Mon, 28 Aug 2000, Dave Thomas wrote:
Robert Feldt <feldt@ce.chalmers.se> writes:
[#4591] Can't get Tcl/Tk working — Stephen White <steve@...>
I can't get any of the samples in the ext/tk/sample directory working. All
I'm sure looking forwards to buying the book. :)
Stephen White <steve@deaf.org> writes:
On Sun, 27 Aug 2000, Dave Thomas wrote:
Stephen White <steve@deaf.org> writes:
[#4608] Class methods — Mark Slagell <ms@...>
Reading the thread about regexp matches made me wonder about this:
[#4611] mod_ruby 0.1.19 — shreeve@...2s.org (Steve Shreeve)
Shugo (and others),
[#4633] Printing tables — DaVinci <bombadil@...>
Hi.
[#4647] Function argument lists in parentheses? — Toby Hutton <thutton@...>
Hello,
[#4652] Andy and Dave's European Tour 2000 — Dave Thomas <Dave@...>
Hi,
[#4672] calling super from c — Robert Feldt <feldt@...>
[#4699] Double parenthesis — Klaus Spreckelsen <ks@...1.ruhr-uni-bochum.de>
Why is the first line ok, but the second line is not?
[ruby-talk:4630] Re: Class methods
Point well taken - though, at the risk of beating a dead wildebeast here,
what I'd begun to wonder about after posting the first message was a
consistent default-semantic for instance method names when invoked as class
methods: "if no class method by that name exists, operate on a new instance
constructed with the given argument(s), if any" -- isn't it true that where
we do have duplicate class methods, this is what we generally expect to
happen anyway? Hmm.
Adding unnecessary methods is, I agree, clumsy, but as a language feature
this could only have the reverse effect, shrinking the standard libraries a
bit by rendering the existing duplicate class methods unnecessary except in
the cases where they need to deviate from that behavior. The question to me
then becomes whether it costs anything in exchange for what it buys, perhaps
in terms of performance.
On the other hand maybe this kind of thing strays a bit too far into the
realm of "Do what I mean", and yes it diverges from OOP conventions. It was
just a strange and fun thought that occurred to me.
And yes, in this particular case, the "File.open(name).read" formulation
seems quite straightforward and elegant.
Mark
Yukihiro Matsumoto wrote:
> Hi,
>
> In message "[ruby-talk:4608] Class methods"
> on 00/08/28, Mark Slagell <ms@iastate.edu> writes:
>
> |Reading the thread about regexp matches made me wonder about this:
> |
> | def File.read(s)
> | File.new(s).read(nil)
> | end
> |
> |Then File.new("filename").read(nil) could be written more simply and
> |readably as File.read("filename") -- rather like "atime" is implemented
> |both as a class method and an instance method. Are there reasons not to
> |do such things? (more methods => performance suffers, perhaps?)
>
> Well, I don't want to provide every method of IO/File as a class
> method like readlines/mtime. It's too clumsy. I'd like to provide
> useful ones. I felt that the method to open file and read a leading
> fixed sized content from it, then close the file, is not quite useful.
>
> But IO#read provides the feature to read whole content too. Now, I
> feel the class method to read whole content may be useful. Although,
>
> File::open(s).read
>
> will do the job (unclosed file will be closed by GC).
>
> matz.