[#15707] Schedule for the 1.8.7 release — "Akinori MUSHA" <knu@...>

Hi, developers,

21 messages 2008/03/01

[#15740] Copy-on-write friendly garbage collector — Hongli Lai <hongli@...99.net>

Hi.

31 messages 2008/03/03
[#15742] Re: Copy-on-write friendly garbage collector — Yukihiro Matsumoto <matz@...> 2008/03/03

Hi,

[#15829] Re: Copy-on-write friendly garbage collector — Daniel DeLorme <dan-ml@...42.com> 2008/03/08

Yukihiro Matsumoto wrote:

[#15756] embedding Ruby 1.9.0 inside pthread — "Suraj Kurapati" <sunaku@...>

Hello,

18 messages 2008/03/03
[#15759] Re: embedding Ruby 1.9.0 inside pthread — Nobuyoshi Nakada <nobu@...> 2008/03/04

Hi,

[#15760] Re: embedding Ruby 1.9.0 inside pthread — Yukihiro Matsumoto <matz@...> 2008/03/04

Hi,

[#15762] Re: embedding Ruby 1.9.0 inside pthread — "Suraj N. Kurapati" <sunaku@...> 2008/03/04

Yukihiro Matsumoto wrote:

[#15783] Adding startup and shutdown to Test::Unit — Daniel Berger <Daniel.Berger@...>

Hi all,

15 messages 2008/03/04

[#15835] TimeoutError in core, timeouts for ConditionVariable#wait — MenTaLguY <mental@...>

I've been reworking JRuby's stdlib to improve performance and fix

10 messages 2008/03/09

[#15990] Recent changes in Range#step behavior — "Vladimir Sizikov" <vsizikov@...>

Hi,

35 messages 2008/03/23
[#15991] Re: Recent changes in Range#step behavior — Dave Thomas <dave@...> 2008/03/23

[#15993] Re: Recent changes in Range#step behavior — "Vladimir Sizikov" <vsizikov@...> 2008/03/23

Hi Dave,

[#15997] Re: Recent changes in Range#step behavior — Dave Thomas <dave@...> 2008/03/23

[#16024] Re: Recent changes in Range#step behavior — "Vladimir Sizikov" <vsizikov@...> 2008/03/26

Hi Dave,

[#16025] Re: Recent changes in Range#step behavior — Yukihiro Matsumoto <matz@...> 2008/03/26

Hi,

[#16026] Re: Recent changes in Range#step behavior — Dave Thomas <dave@...> 2008/03/26

[#16027] Re: Recent changes in Range#step behavior — Yukihiro Matsumoto <matz@...> 2008/03/26

Hi,

[#16029] Re: Recent changes in Range#step behavior — Dave Thomas <dave@...> 2008/03/26

[#16030] Re: Recent changes in Range#step behavior — Yukihiro Matsumoto <matz@...> 2008/03/26

Hi,

[#16031] Re: Recent changes in Range#step behavior — Dave Thomas <dave@...> 2008/03/26

[#16032] Re: Recent changes in Range#step behavior — "Vladimir Sizikov" <vsizikov@...> 2008/03/26

On Wed, Mar 26, 2008 at 7:01 PM, Dave Thomas <dave@pragprog.com> wrote:

[#16033] Re: Recent changes in Range#step behavior — Dave Thomas <dave@...> 2008/03/26

[#16041] Re: Recent changes in Range#step behavior — David Flanagan <david@...> 2008/03/26

Dave Thomas wrote:

Re: Proc#curry doesn't work on func which produces func

From: "Sean E. Russell" <ser@...>
Date: 2008-03-03 14:23:10 UTC
List: ruby-core #15744
On Sunday 02 March 2008, Yusuke ENDOH wrote:
> By the way, I'm curious to know what purpose do people use
> Proc#curry for.

I know you know what currying is for; I'm just throwing some thoughts out=20
there.  It sounds as if you're looking for practical examples for=20
documentation.

A common use for me in FP has been extensible, custom printers.  For exampl=
e,

  logger =3D proc { |level, exception, source, message|
    if level_of( level ) >=3D LogLevel::current_level
      case level
        when :debug
          STDERR.puts "DEBUG [#{source}]: #{message}"
        when :error
          STDERR.puts "ERROR [#{source}]: #{message}"
          STDERR.puts exception.backtrace
        when :info
          STDERR.puts message
      end
  }
  @debug =3D logger.curry.call(:debug).call(nil)
  @error =3D logger.curry.call(:error)
  @info =3D logger.curry.call(:info).call(nil).call(nil)
  ...
 =20
  def some_method()
    ...
    @debug.call( "some_method", "Enter" )
    ...
    begin
      ...
    rescue
      @error.call( "some_method", !$, "It didn't work" )
    end
    ...
  end

Another very common use for currying is for pre-creating commonly used=20
functions that are simple compositions of other functions such as #map and=
=20
#inject.  Even in FP, the choice between using currying and using argument=
=20
tuples is largely one of which is going to be more convenient for the commo=
n=20
use of the function -- although there's an belief that, commonly, currying =
is=20
a better choice.  The logger example above could also be written:

  def logger( level, exception, source, message )
    ...
  end
  def debug( source, message )
    logger( :debug, nil, source, message )
  end

and so on.

=2D-=20
### SER  =20
### Deutsch|Esperanto|Francaise|Linux|XML|Java|Ruby|Haskell|Aikido|Iaido
### http://www.ser1.net, http://www.ser1.net/Security/ser_public.gpg
### Jabber: seanerussell@gmail.com (OTR enabled)

In This Thread

Prev Next