From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.103.134.12 with SMTP id l12cs391474mun; Fri, 16 Oct 2009 11:02:53 -0700 (PDT) Received-SPF: pass (google.com: domain of grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com designates 10.229.69.18 as permitted sender) client-ip=10.229.69.18; Authentication-Results: mr.google.com; spf=pass (google.com: domain of grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com designates 10.229.69.18 as permitted sender) smtp.mail=grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com; dkim=pass header.i=grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com Received: from mr.google.com ([10.229.69.18]) by 10.229.69.18 with SMTP id x18mr1171063qci.26.1255716172495 (num_hops = 1); Fri, 16 Oct 2009 11:02:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:received:x-sender:x-apparently-to :received:received:received:received-spf:received:dkim-signature :domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type:reply-to:sender :precedence:x-google-loop:mailing-list:list-id:list-post:list-help :list-unsubscribe:x-beenthere-env:x-beenthere; bh=oS/kXm+O7HsLXYTPgY6Q0YsgNtNLGdA796yUcPkjQa0=; b=sBfVIvI8/LuK0txaLoCWBzwE7K6GpPdqaTRk5zZPVQ7lK+YXRDynUyJqsJS5aw+x1s vpcj0tUQJzf6h/Xrr+JklSBa0aql0BuQTo/ndY7Uquhp2UeeQJZBeZd32/EDSIVVHZtI lcqS4CemlmB7voFEwAuqLmYy6/zwmutPt+cZc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-sender:x-apparently-to:received-spf:authentication-results :dkim-signature:domainkey-signature:mime-version:in-reply-to :references:from:date:message-id:subject:to:content-type:reply-to :sender:precedence:x-google-loop:mailing-list:list-id:list-post :list-help:list-unsubscribe:x-beenthere-env:x-beenthere; b=pk5Sow7JfyYnLRWiG2bD00YKl+gSCjSARS622ke27hocn29/lzzgX9wI03iU/Sg08g EKMYlArFLsIHsP9FDeamTK39gS7OskxDmpp23JdKX3Y8tIyw1HRkpOhAMOB+1wxydPtL MECk7OuCdYQ8noc7urnNG3YsDC+sm12xrDzNY= Received: by 10.229.69.18 with SMTP id x18mr104915qci.26.1255716172437; Fri, 16 Oct 2009 11:02:52 -0700 (PDT) Received: by 10.177.108.35 with SMTP id k35gr1693yqm.0; Fri, 16 Oct 2009 11:02:48 -0700 (PDT) X-Sender: wycats@gmail.com X-Apparently-To: rack-devel@googlegroups.com Received: by 10.229.55.81 with SMTP id t17mr426268qcg.12.1255716166391; Fri, 16 Oct 2009 11:02:46 -0700 (PDT) Received: by 10.229.55.81 with SMTP id t17mr426267qcg.12.1255716166333; Fri, 16 Oct 2009 11:02:46 -0700 (PDT) Return-Path: Received: from mail-qy0-f190.google.com (mail-qy0-f190.google.com [209.85.221.190]) by gmr-mx.google.com with ESMTP id 18si125025qyk.5.2009.10.16.11.02.45; Fri, 16 Oct 2009 11:02:45 -0700 (PDT) Received-SPF: pass (google.com: domain of wycats@gmail.com designates 209.85.221.190 as permitted sender) client-ip=209.85.221.190; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of wycats@gmail.com designates 209.85.221.190 as permitted sender) smtp.mail=wycats@gmail.com; dkim=pass (test mode) header.i=@gmail.com Received: by mail-qy0-f190.google.com with SMTP id 28so1584862qyk.16 for ; Fri, 16 Oct 2009 11:02:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type; bh=6QTl7KeGl0fSevkzbPP8/ly8gEvjUV447sEsTDkuh+M=; b=YnodWc5QSGToTqRUnamCWTdalXXuz6gBT7xUMmVdwBCzOT+wUDMYCX7BvjvLa5qUQ/ jN/naiKsWK7Esuru1ipmi1QxiVdYrItcqdXA66CRshUDS/LO7BqBvyKc5zpOY3dNxUlt VGXk6BgDwQi2q9mlpUUSuEWv6uGppG9trpjag= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=BajE8xuXq4V8Vj2d8yZv3pwUTCI+ggivPB0hF/N3uemFtwlL7d6CTvD1z3rlR8wOWV AW7RpSBeuj+fC2oFOdplQxMV4N643IutYdK6f6ueDSYzazcgxScunlZ4kmVY3WeRTr70 rWNNd8i9jjeR9/W7fKW/gKIAD2V7mMMyQICGE= MIME-Version: 1.0 Received: by 10.224.93.74 with SMTP id u10mr1201167qam.327.1255716165096; Fri, 16 Oct 2009 11:02:45 -0700 (PDT) In-Reply-To: <200910161948.44121.ibc@aliax.net> References: <200910161948.44121.ibc@aliax.net> From: Yehuda Katz Date: Fri, 16 Oct 2009 11:02:25 -0700 Message-ID: <245fb4700910161102n4daa30b2q375f5a398c2f1f15@mail.gmail.com> Subject: Re: "run Proc.new" using "do ... end" fails ("{ }" required) To: rack-devel@googlegroups.com Content-Type: multipart/alternative; boundary=00c09f88d3eaf5978b04761133e3 Reply-To: rack-devel@googlegroups.com Sender: rack-devel@googlegroups.com Precedence: bulk X-Google-Loop: groups Mailing-List: list rack-devel@googlegroups.com; contact rack-devel+owner@googlegroups.com List-Id: List-Post: List-Help: List-Unsubscribe: , X-BeenThere-Env: rack-devel@googlegroups.com X-BeenThere: rack-devel@googlegroups.com --00c09f88d3eaf5978b04761133e3 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable This is normal Ruby semantics. Consider: method_name another_method do end In this case, the "do" is bound to method_name. Now consider: method_name another_method { } In this case, the {} is bound to another_method. Proc.new is just a normal method, so the above applies. -- Yehuda On Fri, Oct 16, 2009 at 10:48 AM, I=F1aki Baz Castillo wrot= e: > > Hi, the following works: > > > 1 ::Rack::Builder.new do > 2 map "/" do > 3 run Proc.new { |env| > 4 [ 404, {"Content-Type" =3D> "text/plain"}= ), > [""] ] > 5 } > 6 end > 7 end > > > but the following gives an error: > > 1 ::Rack::Builder.new do > 2 map "/" do > 3 run Proc.new do |env| > 4 [ 404, {"Content-Type" =3D> "text/plain"}= ), > [""] ] > 5 end > 6 end > 7 end > > /home/me/myfile.rb:3:in `new': tried to create Proc object without a bloc= k > (ArgumentError) > from /home/me/myfile.rb:3:in `block (2 levels) in core' > from > /usr/local/lib/ruby1.9/gems/1.9.1/gems/rack-1.0.0/lib/rack/builder.rb:29:= in > `instance_eval' > from > /usr/local/lib/ruby1.9/gems/1.9.1/gems/rack-1.0.0/lib/rack/builder.rb:29:= in > `initialize' > from > /usr/local/lib/ruby1.9/gems/1.9.1/gems/rack-1.0.0/lib/rack/builder.rb:46:= in > `new' > from > /usr/local/lib/ruby1.9/gems/1.9.1/gems/rack-1.0.0/lib/rack/builder.rb:46:= in > `map' > from /root/svn_local_copies/OpenXDMS/trunk/lib/rack/core.rb:46:in `block = in > core' > from > /usr/local/lib/ruby1.9/gems/1.9.1/gems/rack-1.0.0/lib/rack/builder.rb:29:= in > `instance_eval' > from > /usr/local/lib/ruby1.9/gems/1.9.1/gems/rack-1.0.0/lib/rack/builder.rb:29:= in > `initialize' > from /home/me/myfile.rb:1:in `new' > ... > > > It fails in ruby 1.8 and 1.9. Why cannot I use "do-end" syntax for a bloc= k > instead of "{ }". Of course, Proc.new does allow "do-end" syntax, so I > wonder > if this issue has something to do with Rack itself. > > > Thanks. > > > -- > I=F1aki Baz Castillo > --=20 Yehuda Katz Developer | Engine Yard (ph) 718.877.1325 --00c09f88d3eaf5978b04761133e3 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable This is normal Ruby semantics.

Consider:

<= /div>
method_name another_method do

end
<= div>
In this case, the "do" is bound to method_name= . Now consider:

method_name another_method {

}=

In this case, the {} is bound to another_method. = Proc.new is just a normal method, so the above applies.

-- Yehuda


On Fri, Oct 16,= 2009 at 10:48 AM, I=F1aki Baz Castillo <ibc@aliax.net> wrote:

Hi, the following works:


1 =A0 =A0 =A0 ::Rack::Builder.new do
2 =A0 =A0 =A0 =A0 =A0 =A0 =A0 map "/" do
3 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 run Proc.new { |env|
4 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 [ 404, {"= ;Content-Type" =3D> "text/plain"}), [""] ]
5 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
6 =A0 =A0 =A0 =A0 =A0 =A0 =A0 end
7 =A0 =A0 =A0 end


but the following gives an error:

1 =A0 =A0 =A0 ::Rack::Builder.new do
2 =A0 =A0 =A0 =A0 =A0 =A0 =A0 map "/" do
3 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 run Proc.new do |env|
4 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 [ 404, {"= ;Content-Type" =3D> "text/plain"}), [""] ]
5 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 end
6 =A0 =A0 =A0 =A0 =A0 =A0 =A0 end
7 =A0 =A0 =A0 end

/home/me/myfile.rb:3:in `new': tried to create Proc object without a bl= ock (ArgumentError)
from /home/me/myfile.rb:3:in `block (2 levels) in core'
from /usr/local/lib/ruby1.9/gems/1.9.1/gems/rack-1.0.0/lib/rack/builder.rb:= 29:in `instance_eval'
from /usr/local/lib/ruby1.9/gems/1.9.1/gems/rack-1.0.0/lib/rack/builder.rb:= 29:in `initialize'
from /usr/local/lib/ruby1.9/gems/1.9.1/gems/rack-1.0.0/lib/rack/builder.rb:= 46:in `new'
from /usr/local/lib/ruby1.9/gems/1.9.1/gems/rack-1.0.0/lib/rack/builder.rb:= 46:in `map'
from /root/svn_local_copies/OpenXDMS/trunk/lib/rack/core.rb:46:in `block in= core'
from /usr/local/lib/ruby1.9/gems/1.9.1/gems/rack-1.0.0/lib/rack/builder.rb:= 29:in `instance_eval'
from /usr/local/lib/ruby1.9/gems/1.9.1/gems/rack-1.0.0/lib/rack/builder.rb:= 29:in `initialize'
from /home/me/myfile.rb:1:in `new'
...


It fails in ruby 1.8 and 1.9. Why cannot I use "do-end" syntax fo= r a block
instead of "{ }". Of course, Proc.new does allow "do-end&quo= t; syntax, so I wonder
if this issue has something to do with Rack itself.


Thanks.


--
I=F1aki Baz Castillo <ibc@aliax.net= >



--
Yehuda Katz
D= eveloper | Engine Yard
(ph) 718.877.1325
--00c09f88d3eaf5978b04761133e3--