[#2367] Standard libraries — Dave Thomas <dave@...>

From ruby-dev summary:

60 messages 2004/02/11

[#2397] PATCH: deprecate cgi-lib, getopts, importenv, parsearg from standard library — Gavin Sinclair <gsinclair@...>

Index: cgi-lib.rb

15 messages 2004/02/12

[#2465] PATCH: OpenStruct#initialize to yield self — Gavin Sinclair <gsinclair@...>

This is a common approach I use to object initialization; I don't know

24 messages 2004/02/19

Re: rb_io_puts is strange

From: Elliott Hughes <ehughes@...>
Date: 2004-02-11 16:10:12 UTC
List: ruby-core #2366
[i've been trying not to respond, but, just for the record...]

> I don't care much about consistency with other languages, for example,
> C etc. as long as the basic behavior remains same.  At least "puts"
> prints the given string with a newline.  Ruby's version is little bit
> "smarter" though.  It wouldn't hurt much, once you've understood.

> This is useful when I output the string from the user.  I didn't need
> to check newlines at the end, nor to chomp the string.

I see. I knew there must be a reason why someone might want this behavior.
I'd also forgotten in the 10 years since I last wrote any C for a system
that had a stdio implementation about the likes of fgets. Speaking as
someone for whom Ruby's competition is Java, I find I never have any problem
with PrintWriter's print/println combined with LineNumberReader's readLine
(which throws away the line-termination characters).

The "smartness" in Ruby is more a case of moving the flaw somewhere else
(from gets to puts). Java -- in this instance -- removes the flaw
completely. *That's* smart.

Don't get me wrong: my Java library contains implementations of Ruby-like
process and file functionality, because I think the Ruby library in those
areas is often As Good As It Gets. Having close throw a checked exception is
a good example of stupidity in Java. (As if 'close' ever guarantees
anything, even if it does complete normally!)

> Are there any bad things remain after you take a few minutes to
> learn the Ruby behavior?

I think so, yes. It's not as strange as ! methods returning nil, but it's
another bit of random strangeness that isn't obviously useful. Except seen
in the light of other decisions.

But, if it's been done on purpose, I just have to shrug my shoulders and
remember to avoid puts and use print("blah\n") instead from now on.

 --elliott


*********************************************************************
This e-mail and any attachment is confidential. It may only be read, copied and used by the intended recipient(s). If you are not the intended recipient(s), you may not copy, use, distribute, forward, store or disclose this e-mail or any attachment. If you are not the intended recipient(s) or have otherwise received this e-mail in error, you should destroy it and any attachment and notify the sender by reply e-mail or send a message to sysadmin@bluearc.com
*********************************************************************


In This Thread

Prev Next