[#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

Comments on base64.rb

From: Gavin Sinclair <gsinclair@...>
Date: 2004-02-12 12:09:29 UTC
List: ruby-core #2395
While adding documentation to base64.rb and backporting it to 1.8, I
noticed that I found the module hard to understand.  Now, I'm not that
familiar with base64 in general, but here are my comments:

 * why must b64encode _print_ a string; why not just return it?

 * having encode64 and b64encode is confusing; they do practcally the
   same thing, and their names don't help distinguish them

 * why not let encode64 take a line length

 * b64encode didn't even appear to work; I'll check for unit tests
   (I didn't see any variation of length of lines with different
   values)


In short, if I were creating a Base64 module, it would look like this.

  module Base64

    def encode64(data, len=nil); ...

    def decode64(str); ...

    def decode_b(str); ...

    # What about encode_b?  Shows how much I know.

  end


This probably isn't considered important, but anyway.  The above
module could become a reality:

 * deprecate b64encode, unless it's actually necessary

 * add optional argument to encode64; it wouldn't change current
   interface


Gavin


In This Thread

Prev Next