[#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: "J.Herre" <jlst@...>
Date: 2004-02-04 18:53:47 UTC
List: ruby-core #2343
On Feb 4, 2004, at 8:17 AM, Elliott Hughes wrote:

> Maybe it's a mindset thing, but to me, a program that doesn't know 
> whether a
> string already ends in a newline is broken. I see a difference with 
> things
> like join, where you don't want a separator on the end, but newlines 
> aren't
> like that (in anything I've ever done, at least).
>

At the risk of sounding old and tired I feel compelled to point out 
that much time and effort over the years have been spent tracking down 
exactly this kind of bug.

Every language that inherits the C Standard Library has had to deal 
with the fact that fgets() and fputs() are not symmetrical.  The reason 
they're not symmetrical is because sometimes the newlines are 
meaningful and sometimes they aren't.  This has led to things like 
chomp().  Of course you know all this.

I too was surprised by ruby's puts() but I find it to be a very elegant 
solution and avoids silly chomp()'s in simple scripts.  The only time 
it doesn't do what you want is when you're trying to format with 
multiple newlines.  In which case it may actually improve the future 
readability of scripts to be explicit.

In any case, in ruby it's easy to override puts() if you like.



In This Thread