rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
From: "Iñaki Baz Castillo" <ibc@aliax.net>
To: Rack Development <rack-devel@googlegroups.com>
Subject: "run Proc.new" using "do ... end" fails ("{ }" required)
Date: Fri, 16 Oct 2009 19:48:43 +0200	[thread overview]
Message-ID: <200910161948.44121.ibc@aliax.net> (raw)


Hi, the following works:


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

/home/me/myfile.rb:3:in `new': tried to create Proc object without a block (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 block
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ñaki Baz Castillo <ibc@aliax.net>

             reply	other threads:[~2009-10-16 17:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-16 17:48 Iñaki Baz Castillo [this message]
2009-10-16 18:02 ` "run Proc.new" using "do ... end" fails ("{ }" required) Yehuda Katz
2009-10-16 18:15   ` Iñaki Baz Castillo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://groups.google.com/group/rack-devel

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200910161948.44121.ibc@aliax.net \
    --to=rack-devel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).