[#177639] memoize to a file — Brian Buckley <briankbuckley@...>

Hello all,

14 messages 2006/02/01

[#177686] ANN: WSS4R was released — "Roland Schmitt" <Roland.Schmitt@...>

Hi everyone,

21 messages 2006/02/01

[#177712] Seeking Continuations Links — James Edward Gray II <james@...>

Myself and a few others are trying to get together a "Playing Around

12 messages 2006/02/01

[#177715] Indentation vs. "end"s — "Rubyist" <nuby.ruby.programmer@...>

Hi,

82 messages 2006/02/01
[#177722] Re: Indentation vs. "end"s — doug00@... 2006/02/01

Yes I really like the end statements, and they make it easier for

[#177943] Re: Indentation vs. "end"s — Hal Fulton <hal9000@...> 2006/02/02

doug00@gmail.com wrote:

[#178227] Re: Indentation vs. "end"s — Michal Suchanek <hramrach@...> 2006/02/03

On 2/2/06, Hal Fulton <hal9000@hypermetrics.com> wrote:> doug00@gmail.com wrote:> > Yes I really like the end statements, and they make it easier for> > beginners. It's possible to support both indenting and end statements> > (i.e. support one mode or the other), and you don't need python's> > redundant and unnecessary colons. I implemented this myself in a> > parser. I don't think it is appropriate for ruby, however.> >> > What would be even better would be to allow optional labels after end> > statements, such as "end class", "end def", so the parser can catch> > more errors.> > I've implemented this as well in a separate project.> >>> Not a bad idea in itself. In fact, I think that really old Ruby> versions (prior to my learning it with 1.4) did something like> that. When modifiers were introduced (x if y, x while y, etc.)> parsing became difficult and they were dropped. I think that's> the case.

[#178134] Re: Indentation vs. "end"s — Yukihiro Matsumoto <matz@...> 2006/02/03

Hi,

[#178139] Re: Indentation vs. "end"s — Cameron McBride <cameron.mcbride@...> 2006/02/03

I'm out of my league, but...

[#177816] neuroimage software - scientific computing and visualization — "Darren L. Weber" <darrenleeweber@...>

20 messages 2006/02/01

[#177902] Job Vacancy RoR — "stephen@..." <stephen@...>

I am part of a small Agency that supplies contractors to clients. A

15 messages 2006/02/01
[#177919] Re: Job Vacancy RoR — tsumeruby@... 2006/02/02

Please use sites like monster or dice if you wish to post jobs. Some have been

[#178072] Job postings? Please! (Was: Re: Job Vacancy RoR) — Eric Hodel <drbrain@...7.net> 2006/02/02

On Feb 1, 2006, at 5:16 PM, tsumeruby@tsumelabs.com wrote:

[#177996] Chomping and stomping — John Maclean <info@...>

Chaps,

17 messages 2006/02/02

[#178218] Splitting the Loot (#65) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

33 messages 2006/02/03

[#178265] Ruby IDEs — Chris <cpmbailey@...>

After years of programming in C++, Java et al my new job used Smalltalk

15 messages 2006/02/03

[#178298] Editor on Mac OS X — "Dan Munk" <danmunk@...>

Hello,

19 messages 2006/02/04

[#178332] Extract hash into local variables? — csn <cool_screen_name90001@...>

Is there a Ruby function similar to PHP's extract/list? What I'd like to

17 messages 2006/02/04

[#178364] Problem with weak references on OS X 10.3 — Caleb Clausen <vikkous@...>

I am having problems with weak references. The program below exhibits

10 messages 2006/02/04

[#178392] Quiz #65, Principle of Great Surprise, and Array.delete sledgehammer — Dave Howell <groups@...>

I thought I was actually going to enter my first RubyQuiz, but I've

25 messages 2006/02/04

[#178393] built-in vs. standard library — Mark Volkmann <r.mark.volkmann@...>

I'm confused about whether the Date class is built-in or in the

11 messages 2006/02/04

[#178416] Scanning a string for decimal numbers — Jeppe Jakobsen <jeppe88@...>

Hi all, how do you scan a string and avoid getting my decimal numbers

23 messages 2006/02/04

[#178579] Ruby jargon and slang — Hal Fulton <hal9000@...>

I'm assembling a list of Ruby community "usages" and I want to make

29 messages 2006/02/06

[#178658] Problems building binaries on OS X 10.4 — "Eric Promislow" <eric.promislow@...>

This is with the Ruby that ships with 10.4 (Tiger). We haven't tried

6 messages 2006/02/06

[#178710] reasons to use else inside rescue — Mark Volkmann <r.mark.volkmann@...>

I understand that the code in the else part of a begin block is only

9 messages 2006/02/07
[#178734] Re: reasons to use else inside rescue — "Robert Klemme" <bob.news@...> 2006/02/07

David Vallner wrote:

[#178752] Re: reasons to use else inside rescue — Mark Volkmann <r.mark.volkmann@...> 2006/02/07

On 2/7/06, Robert Klemme <bob.news@gmx.net> wrote:> David Vallner wrote:> > D Utorok 07 Febru疵 2006 03:33 Mark Volkmann nap﨎al:> >> I understand that the code in the else part of a begin block is only> >> executed if no exceptions are raised by code in the begin block.> >> However, the same is true of code at the end of the begin block. Why> >> not put the code there?> >>> >> For example, I believe these are equivalent.> >>> >> begin> >> do_something> >> rescue> >> handle_exception> >> else> >> do_more_stuff> >> end> >>> >> begin> >> do_something> >> do_more_stuff> >> rescue> >> handle_exception> >> end> >>> >> I suppose a difference is that if "do_more_stuff" raises an> >> exception, the first example can't rescue it and the second might.> >> Is that the only difference?> >>> >> --> >> R. Mark Volkmann> >> Partner, Object Computing, Inc.> >> > There's an else part in a begin / end block?! Oh dear. Heavens> > protect us...>> Why?>> > It seems pretty equivalent to plain old:> >> > begin> > do_something> > rescue> > handle_exception> > end> > do_more_stuff> >> > Do we have a syntax guru to elaborate on this?>> Although not being a syntax guru, the idiom you presented is definitely> *not* equivalent. do_more_stuff will also be called if an exception was> caught and not reraised while code in the "else" branch is only invoked if> there was no exception raised.>> > That said, my wild guess would be that in the code fragment> > (apologies for using different method names):> >> > begin> > foo> > rescue> > bar> > else> > baz> > finally>> "finally" is Java - you probably meant "ensure".>> > quux> > end> >> > (*sic* - messiest code excerpt ever)> >> > if #foo didn't raise an Exception, the order of executions would be> > #foo, #baz, and then #quux. That is, unless the else is nothing more> > than no-op syntactic sugar for just putting the statements after a> > begin / rescue / finally block.>> As Mark said, a *rough* equivalent is to put code in the else part> directly before the first rescue. But they do not have the same> semantics! The difference is that all exceptions raised between "begin"> and "rescue" are potentially subject to exception handling on one of the> "rescue" branches. This is not true for code in the "else" branch.>> Another reason to put code into the else branch is documentation. It's> visibly clear that this code does not belong to the main functionality of> the begin end block but that it's intended to act on successfull execution> of the block.

[#178784] Ruby in Browsers? — petermichaux@...

Hi,

15 messages 2006/02/07
[#178787] Re: Ruby in Browsers? — Gregory Seidman <gsslist+ruby@...> 2006/02/07

On Wed, Feb 08, 2006 at 12:58:26AM +0900, petermichaux@yahoo.com wrote:

[#178808] Start from the start - Ruby or ruby on rails — eain.jones@...

I'm looking to start developing a simple task management application

23 messages 2006/02/07
[#178813] Re: Start from the start - Ruby or ruby on rails — Daniel Nugent <nugend@...> 2006/02/07

I'd say your best bet would be to start with a couple of Ruby

[#178816] Re: Start from the start - Ruby or ruby on rails — Jules Jacobs <devlists-ruby-talk@...> 2006/02/07

I think you meant this one:

[#178854] Re: Start from the start - Ruby or ruby on rails — "Konrad Roziewski" <kroziewski@...> 2006/02/07

I completely agree with Jules: try Rails from the start and learn Ruby

[#178909] Re: Start from the start - Ruby or ruby on rails — eain.jones@... 2006/02/08

Thanks to everybody for the recommendations. I had a lot of the links

[#178965] Re: Start from the start - Ruby or ruby on rails — James Edward Gray II <james@...> 2006/02/08

On Feb 8, 2006, at 3:53 AM, eain.jones@gmail.com wrote:

[#178999] Re: Start from the start - Ruby or ruby on rails — "Seth Thomas Rasmussen" <sethrasmussen@...> 2006/02/08

Hi James,

[#179022] Re: Start from the start - Ruby or ruby on rails — eain.jones@... 2006/02/08

James and Seth,

[#178863] Meta-Meta-Programming — Erik Veenstra <pan@...>

30 messages 2006/02/07

[#178942] boolean annoyance — Claudio Jeker <cjeker@...>

Hello,

28 messages 2006/02/08
[#178949] Re: boolean annoyance — Matthew Moss <matthew.moss.coder@...> 2006/02/08

> there is one thing in ruby that annoys me most (at least for now).

[#179039] Re: boolean annoyance — Claudio Jeker <cjeker@...> 2006/02/08

On Thu, Feb 09, 2006 at 01:16:26AM +0900, Matthew Moss wrote:

[#179063] Re: boolean annoyance — Austin Ziegler <halostatue@...> 2006/02/09

On 08/02/06, Claudio Jeker <cjeker@diehard.n-r-g.com> wrote:

[#179071] Re: boolean annoyance — Claudio Jeker <cjeker@...> 2006/02/09

On Thu, Feb 09, 2006 at 09:15:54AM +0900, Austin Ziegler wrote:

[#180105] Re: boolean annoyance — Austin Ziegler <halostatue@...> 2006/02/16

On 2/8/06, Claudio Jeker <cjeker@diehard.n-r-g.com> wrote:> On Thu, Feb 09, 2006 at 09:15:54AM +0900, Austin Ziegler wrote:> > On 08/02/06, Claudio Jeker <cjeker@diehard.n-r-g.com> wrote:> > >> It's actually the most illogic part of languages like C that treat 0> > >> as false. Believe me, having spent most of my programming life using> > >> C/C++ and being used to that, I make mistakes regularly whilst writing> > >> Ruby code.> > >>> > >> 0 is an integer and quite often a valid value. C's treatment of 0 as> > >> false is convenient in some situations but horribly inconvenient in> > >> others. Because if I'm expecting an integer and zero is a legal> > >> value, then you have to start playing around in your conditionals...> > >> "Okay, today any -1 is false"... or even at different levels than> > >> that. Part of the problem is that C doesn't have an actual NULL...> > >> NULL is just defined as zero. Overlap, explosions, crash and burn...> > > If you are inspecting a integer against nothing end everything is just> > > legal, why are you inspecting it?> >> > Sorry, but that doesn't work. If you have something that returns an> > integer value -- consider strtol(3). This can return *any* valid integer> > value, but if you get a 0, LONG_MAX, or LONG_MIN, you have to *then*> > check errno to see if the conversion was, in fact, successful. (And the> > conversion could be unsuccessful for any number of reasons.)> This is not correct. strtol(3) does not return 0 in case of an error. It> sets errno to ERANGE and returns LONG_MAX or LONG_MIN.

[#178975] Sandboxing eval'd code — eastcoastcoder@...

I'm working on a web app with complicated and ever changing business

19 messages 2006/02/08

[#179035] Geocoder 0.1.0 — Paul Smith <paul@...>

Geocoder is a library for Ruby developers and a command-line utility

13 messages 2006/02/08

[#179121] Ruby on AIX? — Obie Fernandez <obiefernandez@...>

We're looking at big IBM hardware running AIX as a potential

11 messages 2006/02/09

[#179125] Re: Yahoo! Widgets (JavaScript) - do we have a anything like this? — Nuralanur@...

Dear Glenn,

15 messages 2006/02/09
[#179138] Re: Yahoo! Widgets (JavaScript) - do we have a anything like this? — David Vallner <david@...> 2006/02/09

Dňa Štvrtok 09 Február 2006 10:32 Nuralanur@aol.com napísal:

[#179154] Re: Yahoo! Widgets (JavaScript) - do we have a anything like this? — tsumeruby@... 2006/02/09

> I believe Glenn called for something that lets him do desktop applets, not

[#179162] Re: Yahoo! Widgets (JavaScript) - do we have a anything like this? — david@... 2006/02/09

Quoting tsumeruby@tsumelabs.com:

[#179168] Re: Yahoo! Widgets (JavaScript) - do we have a anything like this? — tsumeruby@... 2006/02/09

On Friday 10 February 2006 01:59 am, david@vallner.net wrote:

[#179184] Re: Yahoo! Widgets (JavaScript) - do we have a anything like this? — David Vallner <david@...> 2006/02/09

I had a look at Tile, and it looks promising too. But I tried doing some

[#179216] Re: Yahoo! Widgets (JavaScript) - do we have a anything like this? — tsumeruby@... 2006/02/09

On Friday 10 February 2006 04:54 am, David Vallner wrote:

[#179262] FasterGenerator (#66) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

52 messages 2006/02/10
[#179276] Re: [QUIZ] FasterGenerator (#66) — Matthew Moss <matthew.moss.coder@...> 2006/02/10

Not being familiar with all the various Ruby packages and libs, I

[#179702] Re: [QUIZ] FasterGenerator (#66) — James Edward Gray II <james@...> 2006/02/13

On Feb 10, 2006, at 7:53 AM, Ruby Quiz wrote:

[#179340] why would i want to put my mysql password in the yml file? — trevor <trevor@...>

hello - i'm new!

19 messages 2006/02/11

[#179351] Private methods - only available to oneself? — "minkoo.seo@..." <minkoo.seo@...>

Hi, all.

44 messages 2006/02/11
[#179382] Re: Private methods - only available to oneself? — "Minkoo Seo" <minkoo.seo@...> 2006/02/11

I'm sorry Erik. I'm not native English speaker. So, sometimes it's not

[#179385] Re: Private methods - only available to oneself? — "Erik Veenstra" <google@...> 2006/02/11

> I'm sorry Erik. I'm not native English speaker. So, sometimes

[#179395] Re: Private methods - only available to oneself? — "Phrogz" <gavin@...> 2006/02/11

I think the purpose of instance_eval is one of those "sharp knife"

[#179742] Re: Private methods - only available to oneself? — "Adam P. Jenkins" <thorin@...> 2006/02/13

Phrogz wrote:

[#179366] OpenStruct problem — "Minkoo Seo" <minkoo.seo@...>

OpenStruct class seems to be misbehave when it comes to hashing.

12 messages 2006/02/11

[#179434] Quickly before all is lost! — Alex Combas <alex.combas@...>

ZOMG! Ruby RSS feeds growing exponentially!

15 messages 2006/02/11

[#179447] Rake Friday? — Bil Kleb <Bil.Kleb@...>

Is there a Friday,

23 messages 2006/02/12

[#179503] Cutting a piece of text — Zdebel <szczupienczyk@...>

Helo !

14 messages 2006/02/12

[#179520] Rescuing blocks? — Daniel Nugent <nugend@...>

Hey guys,

26 messages 2006/02/12
[#179523] Re: Rescuing blocks? — David Vallner <david@...> 2006/02/12

Dňa Nedeľa 12 Február 2006 19:26 Daniel Nugent napísal:

[#179524] Re: Rescuing blocks? — Daniel Nugent <nugend@...> 2006/02/12

Whoops, shoulda thought of that, a-doy.

[#179528] Re: Rescuing blocks? — Lou Vanek <vanek@...> 2006/02/12

this works,

[#179531] Re: Rescuing blocks? — Mark Volkmann <r.mark.volkmann@...> 2006/02/12

On 2/12/06, Lou Vanek <vanek@acd.net> wrote:

[#179532] Struct creates non-standard classes — Mark Volkmann <r.mark.volkmann@...>

If Struct is a shorthand way for creating Classes, why don't objects

12 messages 2006/02/12
[#179536] Re: Struct creates non-standard classes — David Vallner <david@...> 2006/02/12

Dňa Nedeľa 12 Február 2006 20:45 Mark Volkmann napísal:

[#179543] Re: Struct creates non-standard classes — Mark Volkmann <r.mark.volkmann@...> 2006/02/12

On 2/12/06, David Vallner <david@vallner.net> wrote:> D Nedeオa 12 Febru疵 2006 20:45 Mark Volkmann nap﨎al:> > If Struct is a shorthand way for creating Classes, why don't objects> > created from those Classes have instance_variables?> >>> My guess is because Struct directly accesses a C hashtable, instead of> registering instance variables in the interpreter. Not like it should matter> unless you for some reason with to access the variables with reflection> instead of the accessors, which I can't imagine why you'd want to do.

[#179554] Re: Struct creates non-standard classes — Robert Klemme <shortcutter@...> 2006/02/12

2006/2/12, Mark Volkmann <r.mark.volkmann@gmail.com>:> On 2/12/06, David Vallner <david@vallner.net> wrote:> > D Nedeオa 12 Febru疵 2006 20:45 Mark Volkmann nap﨎al:> > > If Struct is a shorthand way for creating Classes, why don't objects> > > created from those Classes have instance_variables?

[#179546] Mongrel 0.3.1 -- New Site/Runs Right — Zed Shaw <zedshaw@...>

Hello All,

25 messages 2006/02/12

[#179596] couple quick questions about YARV — Joshua Haberman <joshua@...>

I know YARV is far from finished, but:

11 messages 2006/02/12

[#179623] tree structures — "frank" <mjzanis@...>

Hi,

15 messages 2006/02/13

[#179741] ruby html (or xhtml) forms class... — "Skeets" <skillet3232@...>

does one exist? i use an excellent php based forms class when i code

16 messages 2006/02/13

[#179790] Mongrel 0.3.2 -- The Right Site/All Requests Answered — Zed Shaw <zedshaw@...>

"Another Mongrel release?! Is he insane?" Yeah, basically.

4 messages 2006/02/14
[#179798] Re: [ANN] Mongrel 0.3.2 -- The Right Site/All Requests Answered — Aaron Kulbe <akulbe@...> 2006/02/14

On 2/13/06, Zed Shaw <zedshaw@zedshaw.com> wrote:> "Another Mongrel release?! Is he insane?" Yeah, basically.>> This is yet another release of Mongrel that adds a bunch of little features> people requested and I found were needed. This release is almost entirely> targeted at Ruby on Rails folks as the majority of the changes went into the> mongrel_rails runner.>> Get this release from the (correctly linked) site:>> * http://mongrel.rubyforge.org/ -- project site.> * http://rubyforge.org/frs/?group_id=1306 -- direct to downloads.>>> == What's Mongrel>> Mongrel is a fast HTTP library and server for Ruby that is intended for> hosting Ruby web applications of any kind using plain HTTP rather than> FastCGI or SCGI. It is framework agnostic and already supports Ruby On> Rails, Og+Nitro, and Camping frameworks.>>> == Getting Mongrel>> Simplest way to get Mongrel is through RubyGems. If you've got Ruby On> Rails floating around you just do this:>> $ gem install mongrel (or gem upgrade if you've already got it)> $ cd myrailsapp> $ mongrel_rails start -d>> That runs it in the background in *development* mode on port 3000. Use the> -h option to start to see the various options you have. Stopping it is> just:>> $ mongrel_rails stop>> Win32 people will need to avoid -d until I can test things an get a service> written.>> == Changes>> Lots of little fixes and enhancements that people requested from the last> release.>> * FAQ questions answered on threading and deployment scenarios.> * Added some additional text to make the side icons a little clearer.> * Created a dogs page with some people's favorite pets.> * Write out a better message for 'mongrel_rails start' giving the> environment and other stuff.> * Default to using ENV['RAILS_ENV'] or "default" as environment.> * Removed the restriction on the environments so people can have custom> ones.> * Added options for:> * -n Number of processor threads.> * -t Timeout for each processor before it kills a request.> * -m Specify additional MIME type mappings in YAML format.> * -c Change to directory before starting (both for start and stop> commands)> * -r Use a different document root from "public"> * Use "rb" as open mode on all platforms (for windows binary files)> * Fixed bug in DirHandler which prevented people from altering MIME mapping.>> The big change is the additional options that people have for running Ruby> On Rails applications via Mongrel. Please try them out with your weird> configurations and let me know how they work.>> == Dogs>> Don't forget to check out peoples favorite pets at> http://mongrel.rubyforge.org/dogs.html>> Zed A. Shaw> http://www.zedshaw.com/>>>

[#179860] How to run a Ruby file without installing Ruby? — "Rubyist" <nuby.ruby.programmer@...>

Let's suppose that I wrote a Ruby program which is incredibly

17 messages 2006/02/14

[#179978] gem/rdoc/ri errors on mingw — Alex Combas <alex.combas@...>

Hello,yesterday I switched from the very good, perfectly functionalone-click installer to a build-it-yourself-ruby-compile on winXPwith the mingw environment.

8 messages 2006/02/15

[#180000] Getting Started — lists@...

Hi, I'm trying to get started with Ruby, but I don't feel that any of

14 messages 2006/02/15

[#180012] Possible Ruby-centric NASA SBIR area — Bil Kleb <Bil.Kleb@...>

I've been asked to write a small topic area

20 messages 2006/02/15

[#180021] Ruby script to Module/Class refactor — "James B. Byrne" <ByrneJB@...>

I have written my first live ruby script that actually performs useful

14 messages 2006/02/15

[#180046] OT: Is this worth a try? — "gregarican" <greg.kujawa@...>

I am trying out some other scripting languages and wanted to give

26 messages 2006/02/15
[#180063] Re: OT: Is this worth a try? — David Vallner <david@...> 2006/02/15

Dňa Streda 15 Február 2006 20:33 gregarican napísal:

[#180080] Eating CPAN - Was Port A Library. — John Carter <john.carter@...>

CPAN has 9502 modules.

13 messages 2006/02/16

[#180202] recontextualizing a block (looking for deep magic) — ptkwt@... (Phil Tomson)

What I'm trying to do probably isn't possible, but maybe someone knows some

18 messages 2006/02/16

[#180204] Rubuntu LiveCD I need vim/emacs configs! — Ezra Zygmuntowicz <ezmobius@...>

Friends-

32 messages 2006/02/16
[#182082] Re: Rubuntu LiveCD I need vim/emacs configs! — "Joe" <joesavona@...> 2006/03/01

Just a thought - what about creating a VMware player appliance with all

[#185813] Re: Rubuntu LiveCD I need vim/emacs configs! — "Brandon Hines" <brandonhines@...> 2006/03/25

This topic has been dead for a few days...how's the project coming?

[#185901] Re: Rubuntu LiveCD I need vim/emacs configs! — "ezmobius mob" <ezmobius@...> 2006/03/25

On 3/24/06, Brandon Hines <brandonhines@gmail.com> wrote:

[#180213] Don't let this happen to Ruby, pleeeeease? — Glenn Smith <glenn.ruby@...>

This is quite a good article I just read via a link on artima (I think).

26 messages 2006/02/16
[#180216] Re: Don't let this happen to Ruby, pleeeeease? — James Britt <james_b@...> 2006/02/16

Glenn Smith wrote:

[#180471] Re: Don't let this happen to Ruby, pleeeeease? — "Glenn Smith" <glenn.ruby@...> 2006/02/18

Sorry, posted my rant, then disappeared for two days!

[#180556] Re: Don't let this happen to Ruby, pleeeeease? — David Vallner <david@...> 2006/02/19

Dňa Sobota 18 Február 2006 21:48 Glenn Smith napísal:

[#180566] Re: Don't let this happen to Ruby, pleeeeease? — "Glenn Smith" <glenn.ruby@...> 2006/02/19

SWYgSSByZXByZXNlbnQgaGFsZiBvZiBSdWJ5J3MgdXNlcnMgKG90aGVyIFdpbmRvd3MgdXNlcnMg

[#180280] metakoans.rb (#67) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

80 messages 2006/02/17
[#180334] Re: [QUIZ] metakoans.rb (#67) — "Patrick Hurley" <phurley@...> 2006/02/17

On 2/17/06, Ruby Quiz <james@grayproductions.net> wrote:

[#180335] Re: [QUIZ] metakoans.rb (#67) — ara.t.howard@... 2006/02/17

On Sat, 18 Feb 2006, Patrick Hurley wrote:

[#180337] Re: [QUIZ] metakoans.rb (#67) — "Patrick Hurley" <phurley@...> 2006/02/17

On 2/17/06, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:

[#180338] Re: [QUIZ] metakoans.rb (#67) — ara.t.howard@... 2006/02/17

On Sat, 18 Feb 2006, Patrick Hurley wrote:

[#180341] Re: [QUIZ] metakoans.rb (#67) — "Wilson Bilkovich" <wilsonb@...> 2006/02/18

On 2/17/06, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:

[#180345] Re: [QUIZ] metakoans.rb (#67) — "Jacob Fugal" <lukfugl@...> 2006/02/18

On 2/17/06, Wilson Bilkovich <wilsonb@gmail.com> wrote:

[#180346] Re: [QUIZ] metakoans.rb (#67) — "Wilson Bilkovich" <wilsonb@...> 2006/02/18

On 2/17/06, Jacob Fugal <lukfugl@gmail.com> wrote:

[#180352] Re: [QUIZ] metakoans.rb (#67) — ara.t.howard@... 2006/02/18

On Sat, 18 Feb 2006, Wilson Bilkovich wrote:

[#180355] Re: [QUIZ] metakoans.rb (#67) — "Wilson Bilkovich" <wilsonb@...> 2006/02/18

On 2/17/06, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:

[#180393] Re: [QUIZ] metakoans.rb (#67) — Sylvain Joyeux <sylvain.joyeux@...> 2006/02/18

I'm at 13

[#180404] Re: [QUIZ] metakoans.rb (#67) — "Patrick Hurley" <phurley@...> 2006/02/18

I also have 13; however, two lines exceed 80 columns. Additionally, I

[#180284] Re: Python for Fortran Programmers — Stephan Mueller <d454d@...>

* Bil Kleb <Bil.Kleb@NASA.gov> [060217 11:32]:

13 messages 2006/02/17
[#180285] Re: Python for Fortran Programmers — ara.t.howard@... 2006/02/17

On Sat, 18 Feb 2006, Stephan Mueller wrote:

[#180358] Ruby scripts as Win32-Service — "William Ramirez" <mercan01@...>

I've through together a ruby script as test for a monitoring app for a few

10 messages 2006/02/18
[#180360] Re: Ruby scripts as Win32-Service — "Patrick Hurley" <phurley@...> 2006/02/18

On 2/17/06, William Ramirez <mercan01@gmail.com> wrote:

[#180362] Desktop apps written in Ruby? — petermichaux@...

Hi,

18 messages 2006/02/18
[#180365] Re: Desktop apps written in Ruby? — "Wilson Bilkovich" <wilsonb@...> 2006/02/18

On 2/17/06, petermichaux@yahoo.com <petermichaux@yahoo.com> wrote:

[#180370] Re: Desktop apps written in Ruby? — petermichaux@... 2006/02/18

Thanks for the reply. From that QTRuby link "to create cross-platform

[#180373] Re: Desktop apps written in Ruby? — tsumeruby@... 2006/02/18

On Saturday 18 February 2006 01:08 pm, petermichaux@yahoo.com wrote:

[#180375] Re: Desktop apps written in Ruby? — Scott Weeks <weeksie@...> 2006/02/18

Why not just build the front end of the app in a windows language

[#180378] Re: Desktop apps written in Ruby? — tsumeruby@... 2006/02/18

On Saturday 18 February 2006 02:21 pm, Scott Weeks wrote:

[#180430] best way to use (exploit) mailing list. — John Maclean <info@...>

hey Chaps,

10 messages 2006/02/18

[#180487] maximum number of module methods? — Suraj Kurapati <skurapat@...>

-----BEGIN PGP SIGNED MESSAGE-----

12 messages 2006/02/18

[#180506] lazy.rb 0.9.5 -- transparent futures! — MenTaLguY <mental@...>

I'd like to announce a new version of lazy.rb -- this one offering

43 messages 2006/02/19
[#180853] Re: [ANN] lazy.rb 0.9.5 -- transparent futures! — Andrew Johnson <ajohnson@...> 2006/02/21

On Sun, 19 Feb 2006 10:07:12 +0900, MenTaLguY <mental@rydia.net> wrote:

[#180945] Re: [ANN] lazy.rb 0.9.5 -- transparent futures! — MenTaLguY <mental@...> 2006/02/21

On Tue, 2006-02-21 at 17:33 +0900, Andrew Johnson wrote:

[#180993] Re: lazy.rb 0.9.5 -- transparent futures! — Jim Weirich <jim@...> 2006/02/21

MenTaLguY wrote:

[#180997] Re: lazy.rb 0.9.5 -- transparent futures! — MenTaLguY <mental@...> 2006/02/21

On Wed, 2006-02-22 at 06:49 +0900, Jim Weirich wrote:

[#181023] Re: lazy.rb 0.9.5 -- transparent futures! — Jim Weirich <jim@...> 2006/02/22

MenTaLguY wrote:

[#180698] How can I search value from xml — "Artit Satanakulpanich" <rubybox@...>

How can i search value from xml file such as I want to find from *pubdate *=

15 messages 2006/02/20

[#180709] dirty ranges — dvandeun@... (Dirk van Deun)

I'm a new Ruby user (currently at page 68 of Programming Ruby !) and

12 messages 2006/02/20

[#180811] ANN: Second drop of RubyCLR bridge — "John Lam" <drjflam@...>

This is a much more complete drop of the bridge:

10 messages 2006/02/21

[#180889] Blocks / Closures — Picklegnome <picklegnome@...>

I've just been looking into Ruby in the last few days, and I must say it

14 messages 2006/02/21

[#181027] rubynuby - client side Ruby? — Jeff Pritchard <jp@...>

I would like to be able to do client-side scripting things that in the

19 messages 2006/02/22

[#181181] Mr. Guid 0.2 (Cross-platform Ruby GUI Debugger) — "mitchell" <ffsnoopy@...>

Mr. Guid 0.2 is a milestone release because it can now be run on both

22 messages 2006/02/23

[#181210] compiling c program using rb_eval_string() — hongseok.yoon@...

I tried to call rb_eval_string(), so I wrote simple C code.

6 messages 2006/02/23
[#181213] Re: compiling c program using rb_eval_string() — "Gyoung-Yoon Noh" <nohmad@...> 2006/02/23

On 2/23/06, hongseok.yoon@gmail.com <hongseok.yoon@gmail.com> wrote:> I tried to call rb_eval_string(), so I wrote simple C code.>> #include "/home/xopht/lib/1.8/i686-linux/ruby.h">> int main()> {> rb_eval_string( "puts" );> return 0;> }>> I compiled it and get bellow result.>> [xopht@odin ruby]$ g++ -o test test.cc -lruby-static -L/home/xopht/lib/> /home/xopht/lib//libruby-static.a(string.o)(.text+0x319a): In function> `rb_str_crypt':> /home/xopht/ruby/ruby-1.8.4/string.c:4360: undefined reference to> `crypt'> /home/xopht/lib//libruby-static.a(dln.o)(.text+0x9f): In function> `dln_load':> /home/xopht/ruby/ruby-1.8.4/dln.c:1351: undefined reference to `dlopen'> /home/xopht/lib//libruby-static.a(dln.o)(.text+0xb6):/home/xopht/ruby/ruby-1.8.4/dln.c:1356:> undefined reference to `dlsym'> /home/xopht/lib//libruby-static.a(dln.o)(.text+0x12b):/home/xopht/ruby/ruby-1.8.4/dln.c:1359:> undefined reference to `dlclose'> /home/xopht/lib//libruby-static.a(dln.o)(.text+0x5): In function> `dln_strerror':> /home/xopht/ruby/ruby-1.8.4/dln.c:1193: undefined reference to> `dlerror'> collect2: ld returned 1 exit status> [xopht@odin ruby]$>> what's wrong?>>>

[#181215] Re: compiling c program using rb_eval_string() — "Gyoung-Yoon Noh" <nohmad@...> 2006/02/23

On 2/23/06, Gyoung-Yoon Noh <nohmad@gmail.com> wrote:> On 2/23/06, hongseok.yoon@gmail.com <hongseok.yoon@gmail.com> wrote:> > I tried to call rb_eval_string(), so I wrote simple C code.> >> > #include "/home/xopht/lib/1.8/i686-linux/ruby.h"> >> > int main()> > {> > rb_eval_string( "puts" );> > return 0;> > }> >> > I compiled it and get bellow result.> >> > [xopht@odin ruby]$ g++ -o test test.cc -lruby-static -L/home/xopht/lib/> > /home/xopht/lib//libruby-static.a(string.o)(.text+0x319a): In function> > `rb_str_crypt':> > /home/xopht/ruby/ruby-1.8.4/string.c:4360: undefined reference to> > `crypt'> > /home/xopht/lib//libruby-static.a(dln.o)(.text+0x9f): In function> > `dln_load':> > /home/xopht/ruby/ruby-1.8.4/dln.c:1351: undefined reference to `dlopen'> > /home/xopht/lib//libruby-static.a(dln.o)(.text+0xb6):/home/xopht/ruby/ruby-1.8.4/dln.c:1356:> > undefined reference to `dlsym'> > /home/xopht/lib//libruby-static.a(dln.o)(.text+0x12b):/home/xopht/ruby/ruby-1.8.4/dln.c:1359:> > undefined reference to `dlclose'> > /home/xopht/lib//libruby-static.a(dln.o)(.text+0x5): In function> > `dln_strerror':> > /home/xopht/ruby/ruby-1.8.4/dln.c:1193: undefined reference to> > `dlerror'> > collect2: ld returned 1 exit status> > [xopht@odin ruby]$> >> > what's wrong?> >> >> >>> rb_string_eval() needs to be initialized properly.> Check this,> http://phrogz.net/ProgrammingRuby/ext_ruby.html#extendingruby> http://www.rubygarden.org/ruby?EmbedRuby>> --> http://nohmad.sub-port.net>

[#181224] Ruby as First Language — "woodyee" <wood_yee12@...>

Hi! I'm interested in getting opinions on Ruby as a first language. For

55 messages 2006/02/23
[#181479] Re: Ruby as First Language — "Timothy Goddard" <interfecus@...> 2006/02/24

My order was Quick BASIC, then C++, PHP, then Ruby. I found the

[#181520] Re: Ruby as First Language — Gregory Seidman <gsslist+ruby@...> 2006/02/25

On Sat, Feb 25, 2006 at 08:13:34AM +0900, Timothy Goddard wrote:

[#181526] Re: Ruby as First Language — "Chris Pine" <chris@...> 2006/02/25

On 2/25/06, Gregory Seidman <gsslist+ruby@anthropohedron.net> wrote:> 1) Logo as a preteen, or AWK and/or Bourne shell scripting at any age> 2) C (second procedural language)> 3) Ruby, Python, Java, or C# (first OOP language)

[#181261] Creating Ruby Classes from XSD? — "Justin Bailey" <jgbailey@...>

.NET ships with a tool that will generate classes directly from an XML

15 messages 2006/02/23

[#181291] LibXML-Ruby 0.3.6 — Ross Bamford <rossrt@...>

LibXML-Ruby 0.3.6 is now available from Rubyforge. LibXML-Ruby is (as

29 messages 2006/02/23

[#181315] Huge performance gap — Alexis Reigel <mail@...>

Hi all

79 messages 2006/02/23
[#181318] Re: Huge performance gap — "E. Saynatkari" <none@...> 2006/02/23

Alexis Reigel wrote:

[#199810] Re: Huge performance gap — Reggie Mr <buppcpp@...> 2006/07/01

Here is a simple graph of performance by different platforms.

[#199814] Re: Huge performance gap — "Austin Ziegler" <halostatue@...> 2006/07/01

On 7/1/06, Reggie Mr <buppcpp@yahoo.com> wrote:

[#199841] Re: Huge performance gap — "M. Edward (Ed) Borasky" <znmeb@...> 2006/07/01

Austin Ziegler wrote:

[#199864] Re: Huge performance gap — "Robert Klemme" <shortcutter@...> 2006/07/01

2006/7/1, M. Edward (Ed) Borasky <znmeb@cesmail.net>:

[#199885] Re: Huge performance gap — Reggie Mr <buppcpp@...> 2006/07/02

Austin Ziegler wrote:

[#199889] Re: Huge performance gap — Daniel DeLorme <dan-ml@...42.com> 2006/07/02

Reggie Mr wrote:

[#199890] Re: Huge performance gap — "Francis Cianfrocca" <garbagecat10@...> 2006/07/02

>

[#199915] Ruby and Rails performance profiling? — Robert Mela <rmela@...> 2006/07/02

What tools exist for profiling Ruby?

[#199916] Re: Ruby and Rails performance profiling? — "Francis Cianfrocca" <garbagecat10@...> 2006/07/02

Ruby has a built-in profiler. Fair enough, let's run it, it would be

[#199931] Re: Ruby and Rails performance profiling? — "M. Edward (Ed) Borasky" <znmeb@...> 2006/07/02

Francis Cianfrocca wrote:

[#181316] Fwd: Launching Ruby scripts and the future of MVM — "Charles O Nutter" <headius@...>

I tossed this message off to the Ruby-core list about a month ago, and

11 messages 2006/02/23
[#181325] Re: Launching Ruby scripts and the future of MVM — gwtmp01@... 2006/02/23

[#181343] Re: Launching Ruby scripts and the future of MVM — Logan Capaldo <logancapaldo@...> 2006/02/23

[#181377] Re: Launching Ruby scripts and the future of MVM — gwtmp01@... 2006/02/24

[#181379] Re: Launching Ruby scripts and the future of MVM — "Austin Ziegler" <halostatue@...> 2006/02/24

On 2/23/06, gwtmp01@mac.com <gwtmp01@mac.com> wrote:> On Feb 23, 2006, at 6:20 PM, Logan Capaldo wrote:>> On Feb 23, 2006, at 5:42 PM, gwtmp01@mac.com wrote:>>> On Feb 23, 2006, at 5:05 PM, Charles O Nutter wrote:>>>> I tossed this message off to the Ruby-core list about a month ago,>>>> and sent a follow-up email today. The basic idea is that if there>>>> were a Kernel#run_script method or similar, all Ruby apps that want>>>> to launch external scripts could do so in a platform and>>>> implementation-independent way.>>> In what way is what you are proposing different from Kernel#system?>> system(x) # x is arbitrary shell command>> run_script(x) # x is guaranteed to be a script written in ruby>>>> This means for instance, that run_script could get away with not>> forking a new process, but rather just a new ruby VM assuming that>> the ruby implementation had that capability> You already have coroutines, threads, fork/exec, system, and load/> require all of which give you different ways to manage multiple> threads of control and/or interpret external ruby code.

[#181420] Current Temperature (#68) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

25 messages 2006/02/24

[#181542] FasterCSV 0.1.6 -- With Header Support! — James Edward Gray II <james@...>

FasterCSV 0.1.6 Released

25 messages 2006/02/26
[#181543] Re: [ANN] FasterCSV 0.1.6 -- With Header Support! — "Gregory Brown" <gregory.t.brown@...> 2006/02/26

On 2/25/06, James Edward Gray II <james@grayproductions.net> wrote:

[#181705] Re: [ANN] FasterCSV 0.1.6 -- With Header Support! — James Edward Gray II <james@...> 2006/02/27

On Feb 25, 2006, at 7:22 PM, Gregory Brown wrote:

[#181667] Ruby Whitespace Semantics — Almann Goo <almann.goo@...>

Can someone please explain the semantics behind the following:

21 messages 2006/02/27

[#181690] string contains one of these??? — mikkel <mikkel@...>

Imagine,

17 messages 2006/02/27

[#181710] Dynamic stuff and books — Mc Osten <riko@...>

I started using ruby a couple of weeks ago and it's time to make a couple

14 messages 2006/02/27

[#181774] :-( — "Joe Van Dyk" <joevandyk@...>

Someone needs to make a "C++ for Ruby programmers" book. I'm getting

17 messages 2006/02/28

[#181812] Subclassing Struct.new — "Minkoo Seo" <minkoo.seo@...>

Hi group.

37 messages 2006/02/28
[#181814] Re: Subclassing Struct.new — "chiaro scuro" <kiaroskuro@...> 2006/02/28

On 2/28/06, Minkoo Seo <minkoo.seo@gmail.com> wrote:

[#181816] Re: Subclassing Struct.new — "Minkoo Seo" <minkoo.seo@...> 2006/02/28

It works! Thank you.

[#181819] Re: Subclassing Struct.new — "chiaro scuro" <kiaroskuro@...> 2006/02/28

On 2/28/06, Minkoo Seo <minkoo.seo@gmail.com> wrote:

[#181858] Re: Subclassing Struct.new — mental@... 2006/02/28

Quoting chiaro scuro <kiaroskuro@gmail.com>:

[#181862] Re: Subclassing Struct.new — "chiaro scuro" <kiaroskuro@...> 2006/02/28

On 2/28/06, mental@rydia.net <mental@rydia.net> wrote:

[#181885] rcov 0.2.0 - code coverage tool for Ruby — Mauricio Fernandez <mfp@...>

Source code, additional information, screenshots... available at

18 messages 2006/02/28

[SUMMARY] Port a Library (#64)

From: Ruby Quiz <james@...>
Date: 2006-02-02 13:37:43 UTC
List: ruby-talk #177982
The great element of porting a library is that you get examine another
programmer's ideas.  If you're lucky, that may teach you a new trick or two. 
I'll use my experience as an example.

	Using Buffers

When I decided to port File::ReadBackwards, the first question I asked myself
was, how do you read a file backwards?  I decided that you would need to put the
read head at the end of the file, then work it backwards bit by bit.  You can't
return a line until you have the whole thing, so I knew I would need to buffer
the reads.  I guessed I would be sure I had a line when I had seen two line
endings (whatever is between them is a line) or run into the beginning of the
file (no more data).  That actually turns out to be the rough process, but,
luckily for me, Uri Guttman is smarter than me and reading Uri's code taught me
a couple of tricks.

Here's a simplified version of my port, showing only the interesting methods:

	# Based on Perl's File::ReadBackwards module, by Uri Guttman.
	class Elif
	  MAX_READ_SIZE = 1 << 10  # 1024
	  
	  def initialize( *args )
	    @file = File.new(*args)
	    @file.seek(0, IO::SEEK_END)
	  
	    @current_pos = @file.pos
	  
	    @read_size = @file.pos % MAX_READ_SIZE
	    @read_size = MAX_READ_SIZE if @read_size.zero?
	  
	    @line_buffer = Array.new
	  end
	  
	  def gets( sep_string = $/ )
	    return @line_buffer.pop if @line_buffer.size > 2 or @current_pos.zero?
	  
	    @current_pos -= @read_size
	    @file.seek(@current_pos, IO::SEEK_SET)
	  
	    @line_buffer[0] = "#{@file.read(@read_size)}#{@line_buffer[0]}"
	    @read_size      = MAX_READ_SIZE  # Set a size for the next read.
	  
	    @line_buffer[0] =
	      @line_buffer[0].scan(/.*?#{Regexp.escape(sep_string)}|.+/)
	    @line_buffer.flatten!
	  
	    gets(sep_string)
	  end
	end

You can see the first trick Uri taught me in initialize().  Working the pointer
backwards can be messy.  You have to keep track of where you are, shift the read
pointer back, read some, but always make sure you have that many bytes left. 
There's an easier way.

If you pick some number of bytes you are going to read, you can consider the
file to be in chunks that size.  For example, if we are going to read ten bytes
at a time and have a twenty-four byte file, we can deal with it in chunks of
ten, ten, and four.  The only odd chunk size is at the end, where we start, so
we can deal with that immediately and then all future reads can be whatever
chunk size we selected.

That's what initialize() is doing:  Open the file, jump to the end, and set that
initial read size to handle the dangling partial chunk.

Now we can tackle gets() and I'll tell you about the other lesson Uri taught me.
First, the function of gets() is pretty basic:  If we know we have a line or
that we are out of lines, return it or nil.  Otherwise, read some more data,
trying to make one of those two exit conditions true, and recurse.  The only
hard part is deciding when we have a line.

I was dreaming up a complicated solution to this, when reading Uri's code showed
me the light.  You can store the data in the buffer exactly like it is in the
file (or whatever we've read of it so far).  We will break it at lines though,
because that's what we're interested in reading.  At any given time, it's very
likely the buffer holds a partial line (because we haven't seen the rest). 
However, if we have at least two lines buffered, we can return one immediately. 
One of them is likely a partial sure, but the last one, the one the user wants,
must be full now.  This is easy to code, as you can see above.

In gets(), I prepend each read to the first (likely partial) line.  Then I use
scan() to find all the lines in there, creating an Array, then flatten!() to
fold those lines back into the buffer, discarding the extra Array.

Thanks for the lessons Uri!

You really pick these insights up from reading the code of others, which is why
I think reading code is important.  This is one of the big perks of running the
Ruby Quiz.  I get to read a lot of code and the submissions are always teaching
me things.  This week was no different, so now let me tell you what I learned
from others.

	Lazy Evaluation

This next library came at just the right time for me.  I'm reading Higher-Order
Perl, by Mark Jason Dominus, and trying to apply the ideas I am learning there
to my Ruby usage.  One of the big concepts in the book is "lazy" code, which is
just a fancy way of saying, I want to run this... later.

There are a lot of advantages to something like this.  If an operation is
expensive in computational terms, we can assure that it doesn't happen until it
is needed.  The advantage to that is that it may not be needed at all, which
keeps us from wasting time.

Another less-used example is that we can delay evaluation until we have more
information.  The standard PStore library is a great example here.  You pass it
the path to the cache file in initialize(), but it waits until transaction() to
actually open the file.  The reason is that you can start a "read-only"
transaction, or a normal transaction that allows reading and writing.  By
waiting to open the file, PStore knows the right mode to use, the right level of
file locking to apply, etc.

The tricky part to lazy evaluation, for me at least, is just getting your head
around it.  When you decide you're ready though, here is an excellent first
step:

	module Trampoline
	   # Instance methods
	   class Bounce
	      def initialize(cons, klass, *args)
	         @klass, @cons, @args = klass, cons, args
	      end
	      
	      def method_missing(method, *args)
	         @obj = @klass.send(@cons, *@args) unless @obj
	         @obj.send(method, *args)
	      end
	   end
	   
	   # Class methods
	   class << Bounce
	      alias_method :old_new, :new
	      
	      def new(*args)
	         old_new(:new, *args)
	      end
	      
	      def method_missing(method, *args)
	         old_new(method, *args)
	      end
	   end
	end

That's Matthew Moss's port of the Perl Trampoline module, by Steven Lembark. 
Let's break down what this does.

First, the instance methods.  It seems that initialize() doesn't do anything
except store some information.  We will find out what for in method_missing().

Remember that method_missing() will be called for any message we haven't
defined.  In this case, that's pretty much everything.  (More on that in a
minute...)  When called, method_missing() makes sure @obj is defined.  If it's
not, it is created by calling the proper cons(tructor) with the args
initialize() tucked away.  Then the message is just forwarded to @obj.  That
means the object is built just before the first method call, then reused to
handle all future method calls.

The only problem with the above strategy is that Bounce includes some default
Ruby methods inherited from Object.  This means that something like a to_s()
call isn't forwarded.  You can fix this by adding something like the following
to Bounce:

	instance_methods.each { |m| undef_method m unless m =~ /^__/ }

Now let's look at the class methods. You can see that new() is moved and
redefined, to change its interface for calling code.  Now we see another
method_missing(), this time for the class itself.  It works just like the
redefined new(), forwarding the message to the constructor.  Remember, not all
objects are constructed with new().  Singleton objects often use instance(), for
example.  This method allows for that.  Whatever is called will later be used to
build the object.

That's a great introduction to lazy evaluation.  When that sinks in a bit and
you're ready for more, see the excellent lazy.rb library by MenTaLguY:

	http://moonbase.rydia.net/software/lazy.rb/

	Currying

Another interesting technique discussed in Higher-Order Perl was also
represented in the solutions to this quiz.  Ross Bamford ported Perl's
Sub::Curry module by Johan Lodin.  Currying is basically the process of using
functions to manufacture other functions, as seen in these simple examples:

	require "curry"
	
	scale = lambda { |size, object| object * size }
	
	puts "3 scaleded to a size of 10 is #{scale[10, 3]}."  # 30
	puts
	
	# curry some functions
	double = scale.curry(2)
	triple = scale.curry(3)
	halve  = scale.curry(0.5)
	
	puts "4 doubled is #{double[4]}."   # 8
	puts "1 tripled is #{triple[1]}."   # 3
	puts "Half of 10 is #{halve[10]}."  # 5.0

The great side of this library is that it can handle much more complicated
argument setups than this.  For example, what if the arguments to scale had been
reversed?  No problem:

	scale = lambda { |object, size| object * size }
	
	puts "3 scaleded to a size of 10 is #{scale[10, 3]}."  # 30
	puts
	
	# we can leave "holes" in the argument list
	double = scale.curry(Curry::HOLE, 2)
	triple = scale.curry(Curry::HOLE, 3)
	halve  = scale.curry(Curry::HOLE, 0.5)
	
	puts "4 doubled is #{double[4]}."   # 8
	puts "1 tripled is #{triple[1]}."   # 3
	puts "Half of 10 is #{halve[10]}."  # 5.0

That works exactly the same, but if you're not impressed yet we can get even
fancier.  The library already supports a bunch of "spices", like HOLE above, but
you can also add your own:

	# Lazy Evaluation meets Currying...
	class LazySpice < Curry::SpiceArg
	  def initialize( &promise )
	    super("LAZYSPICE")
	    
	    @promise = promise
	  end
	  
	  def spice_arg( args )  # called to provide the missing argument
	    [@promise.call]
	  end
	end
	
	logger = lambda do |time, message|
	  puts "[#{time.strftime('%I:%M:%S %p %m/%d/%y')}] #{message}"
	end
	
	log_now = logger.curry(LazySpice.new { Time.now })
	
	log_now["First Message."]   # => [12:47:53 PM 02/01/06] First Message.
	sleep 3
	log_now["Second Message."]  # => [12:47:56 PM 02/01/06] Second Message.

Notice how the LazySpice isn't evaluated until the time of the call.  That lazy
execution makes sure our message is stamped with the time it was actually
logged.

I'm not going to show the library here, since I've gone on long enough, but I
hope you will agree that it's worth a look.

	Wrap Up

Please take some time to look into the other solutions I didn't cover here.  All
of them were interesting ideas and I hope their authors will consider packaging
them up for all to use.

Myself, and others, were worried that this would not be a popular quiz.  It far
exceeded my expectations though and I owe a big thank you to all who made that
happen!  You are all so clever it makes even me look good.

We'll go back to a more traditional Ruby Quiz problem tomorrow, I promise.  This
time we will borrow a problem from the Code Katas...

In This Thread

Prev Next