Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Toward a Design for Ruby

brixen
November 01, 2012

Toward a Design for Ruby

RubyConf 2012 talk about the design of Ruby.

brixen

November 01, 2012
Tweet

More Decks by brixen

Other Decks in Programming

Transcript

  1. $ irb 1.9.3p286 :001 > a = "abc".force_encoding "ascii-8bit" =>

    "abc" 1.9.3p286 :002 > b = "\xff".force_encoding "us-ascii" => "\xFF" 1.9.3p286 :003 > a + b => "abc\xFF" Thursday, November 1, 2012
  2. $ irb 1.9.3p286 :001 > a = "\xFF".force_encoding 'ascii-8bit' =>

    "\xFF" 1.9.3p286 :002 > b = "\x98".force_encoding 'us-ascii' => "\x98" 1.9.3p286 :003 > a + b Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and US- ASCII Thursday, November 1, 2012
  3. If one instance of monkey patching is bad, then N

    instances will be fine Thursday, November 1, 2012
  4. Any proposed change to Ruby MUST have: a. Documentation. b.

    RubySpec coverage. c. Implementation by all members. d. Debate. e. A vote. Thursday, November 1, 2012
  5. $ bin/mspec library/stringio/gets -fs rubinius 2.0.0dev (1.9.3 580680b8 yyyy-mm-dd JI)

    [x86_64-apple-darwin10.8.0] StringIO#gets when passed [separator] - returns the data read till the next occurence of the passed separator - sets $_ to the read content - accepts string as separator - updates self's lineno by one - returns the next paragraph when the passed separator is an empty String - returns the remaining content starting at the current position when passed nil - tries to convert the passed separator to a String using #to_str StringIO#gets when passed no argument - returns the data read till the next occurence of $/ or till eof - sets $_ to the read content - updates self's position - updates self's lineno - returns nil if self is at the end StringIO#gets when passed [limit] - returns the data read until the limit is met - sets $_ to the read content - updates self's lineno by one - tries to convert the passed limit to an Integer using #to_int - returns a blank string when passed a limit of 0 StringIO#gets when passed [separator] and [limit] - returns the data read until the limit is consumed or the separator is met - sets $_ to the read content - updates self's lineno by one - tries to convert the passed separator to a String using #to_str - does not raise TypeError if passed separator is nil - tries to convert the passed limit to an Integer using #to_int - raises a TypeError if both separator and limit are nil StringIO#gets when in write-only mode - raises an IOError Thursday, November 1, 2012
  6. “It is a beautiful, powerful language. It brings many people

    such joy.” Thursday, November 1, 2012
  7. “Ruby is now over 18 years old. Please set it

    free to fulfill its destiny.” Thursday, November 1, 2012