[#356306] UTF8 hell — Xavier No謖le <xavier.noelle@...>

Hello,

15 messages 2010/02/02
[#356309] Re: [ENCODING] UTF8 hell — David Palm <dvdplm@...> 2010/02/02

> I fetch rows from an UTF8 database and try to work with the string. To

[#356317] Why Ruby? — Jim Maher <jdmaher@...>

I've asked several friends and associates (application developers) what

52 messages 2010/02/02

[#356439] rdoc_osx_dictionary 1.2.0 Released — Ryan Davis <ryand-ruby@...>

rdoc_osx_dictionary version 1.2.0 has been released!

14 messages 2010/02/03

[#356451] Error: uninitialized constant Mysql::Protocol::UNIXSocket — Shahab Qadeer <shahab_qadeer@...>

/!\ FAILSAFE /!\ Wed Feb 03 23:02:50 +0500 2010

15 messages 2010/02/03

[#356459] hooking subscript operations in a hash — Ralph Shnelvar <ralphs@...32.com>

In order to help debug something, I'd like to hook the hash subscript operation.

17 messages 2010/02/04
[#356461] Re: hooking subscript operations in a hash — Rick DeNatale <rick.denatale@...> 2010/02/04

On Wed, Feb 3, 2010 at 9:38 PM, Ralph Shnelvar <ralphs@dos32.com> wrote:

[#356462] Re: hooking subscript operations in a hash — Ralph Shnelvar <ralphs@...32.com> 2010/02/04

RD> On Wed, Feb 3, 2010 at 9:38 PM, Ralph Shnelvar <ralphs@dos32.com> wrote:

[#356489] Some noob questions — John Ydil <john.gendrot@...>

Hello Ruby friends!

29 messages 2010/02/04
[#356494] Re: Some noob questions — Robert Klemme <shortcutter@...> 2010/02/04

On 02/04/2010 11:58 AM, John Ydil wrote:

[#356568] Re: Some noob questions — Albert Schlef <albertschlef@...> 2010/02/04

Robert Klemme wrote:

[#356605] Re: Some noob questions — Robert Klemme <shortcutter@...> 2010/02/05

On 05.02.2010 00:10, Albert Schlef wrote:

[#356624] Re: Some noob questions — Albert Schlef <albertschlef@...> 2010/02/05

Robert Klemme wrote:

[#356626] Re: Some noob questions — Robert Klemme <shortcutter@...> 2010/02/05

On 02/05/2010 12:50 PM, Albert Schlef wrote:

[#356628] Re: Some noob questions — Albert Schlef <albertschlef@...> 2010/02/05

Robert Klemme wrote:

[#356665] Re: Some noob questions — Robert Klemme <shortcutter@...> 2010/02/05

On 02/05/2010 02:01 PM, Albert Schlef wrote:

[#356811] Re: Some noob questions — Aldric Giacomoni <aldric@...> 2010/02/08

Robert Klemme wrote:

[#356814] Re: Some noob questions — Robert Klemme <shortcutter@...> 2010/02/08

2010/2/8 Aldric Giacomoni <aldric@trevoke.net>:

[#356531] Finding duplicate records before creating using FasterCSV — John Mcleod <john.mcleod@...>

Hello all,

11 messages 2010/02/04

[#356563] Can Ruby Do This? — Mr Bubb <jcabraham@...>

In Perl, you can create a hash of arbitrary depth like so:

14 messages 2010/02/04

[#356685] Google AI Challenge at U of Waterloo — Forthminder <mentifex@...>

Contest runs from 4 February to 26 February 2010.

11 messages 2010/02/06

[#356716] match/scan does not return multiple matches — Michal Suchanek <hramrach@...>

Hello

12 messages 2010/02/06

[#356744] Honest opinion needed... — Schala Zeal <schalaalexiazeal@...>

I've been trying to find a scripting language to integrate into a game

15 messages 2010/02/07

[#356769] C embed assistance — Schala Zeal <schalaalexiazeal@...>

I was wondering if there was a site with reliable documentation covering

15 messages 2010/02/07

[#356792] Why no ++ and --? — Sonja Elen Kisa <sonja@...>

"foo += 1" somehow seems less elegant or pretty as "foo++".

27 messages 2010/02/08

[#356882] "Code must be Chunkable" — Intransition <transfire@...>

I watched Part 1 of this great lecture, and I just had to share:

46 messages 2010/02/08
[#356943] Re: "Code must be Chunkable" — Brian Candler <b.candler@...> 2010/02/09

Thomas Sawyer wrote:

[#357074] Re: "Code must be Chunkable" — Intransition <transfire@...> 2010/02/11

On Feb 9, 11:40 am, Brian Candler <b.cand...@pobox.com> wrote:

[#356944] Need Code to Create Directory Picking Dialog Box — Alex DeCaria <alex.decaria@...>

I have a Ruby program and want to be able to pick a directory using a

14 messages 2010/02/09

[#357030] Exit method? — Charlie Ca <artemisc360@...>

Hello World,

23 messages 2010/02/10
[#357033] Re: Exit method? — Marnen Laibow-Koser <marnen@...> 2010/02/10

Charlie Ca wrote:

[#357103] Can SWIN CommonDialog.openFilename() select multiple files? — Alex DeCaria <alex.decaria@...>

12 messages 2010/02/11

[#357170] how to detect used protocol (SOAP, JSON, XML etc.) — jeljer te Wies <jeljer@...>

Hi guys!.

15 messages 2010/02/12

[#357187] Is there a way to get a method to always run at the end of any descendent's initialize method? — Xeno Campanoli <xeno.campanoli@...>

I have an initialize method I want to run at the end of any daughter or

11 messages 2010/02/12

[#357249] Generating all possible combinations of a 5 digit pattern. — Zach Bartels <no@...>

This is probably childs play for most of you.. But I lack the

17 messages 2010/02/13

[#357446] Dia 1.1 released! — Robert Gleeson <rob@...>

Hey

17 messages 2010/02/16
[#357451] Re: Dia 1.1 released! — Daniel Berger <djberg96@...> 2010/02/16

[#357453] Re: Dia 1.1 released! — Robert Gleeson <rob@...> 2010/02/16

Dan --

[#357909] Re: Dia 1.1 released! — Robert Gleeson <rob@...> 2010/02/23

I'm just leaving an update:

[#357485] Tk on Windows and Mac OS X 10.6 — Eric Christopherson <echristopherson@...>

Is it possible to install Ruby Tk bindings on Windows with

37 messages 2010/02/16
[#357491] Re: Tk on Windows and Mac OS X 10.6 — Albert Schlef <albertschlef@...> 2010/02/16

Eric Christopherson wrote:

[#357492] Re: Tk on Windows and Mac OS X 10.6 — Eric Christopherson <echristopherson@...> 2010/02/17

On Tue, Feb 16, 2010 at 5:57 PM, Albert Schlef <albertschlef@gmail.com> wrote:

[#357496] Re: Tk on Windows and Mac OS X 10.6 — Albert Schlef <albertschlef@...> 2010/02/17

Eric Christopherson wrote:

[#357548] Where is Ruby 1.9 'TK' library? — Alex DeCaria <alex.decaria@...>

Just installed Ruby 1.9 and tried to run one of my TK applications that

31 messages 2010/02/17
[#357559] Re: Where is Ruby 1.9 'TK' library? — Luis Lavena <luislavena@...> 2010/02/17

On Feb 17, 7:36m, Alex DeCaria <alex.deca...@millersville.edu>

[#357567] Re: Where is Ruby 1.9 'TK' library? — Eric Christopherson <echristopherson@...> 2010/02/17

On Wed, Feb 17, 2010 at 3:10 PM, Luis Lavena <luislavena@gmail.com> wrote:

[#357570] Re: Where is Ruby 1.9 'TK' library? — Roger Pack <rogerpack2005@...> 2010/02/17

> Luis, is it possible at all to *add* Tk bindings to a copy of Ruby

[#357572] Re: Where is Ruby 1.9 'TK' library? — Eric Christopherson <echristopherson@...> 2010/02/18

On Wed, Feb 17, 2010 at 5:40 PM, Roger Pack <rogerpack2005@gmail.com> wrote:

[#357577] Re: Where is Ruby 1.9 'TK' library? — Alex DeCaria <alex.decaria@...> 2010/02/18

Roger Pack wrote:

[#357583] Re: Where is Ruby 1.9 'TK' library? — Roger Pack <rogerpack2005@...> 2010/02/18

[#358598] Re: Where is Ruby 1.9 'TK' library? — Alex DeCaria <alex.decaria@...> 2010/03/05

Roger Pack wrote:

[#357617] strings combine — Roger Pack <rogerpack2005@...>

Shouldn't the following be a syntax error?

24 messages 2010/02/18
[#357618] Re: strings combine — Gary Wright <gwtmp01@...> 2010/02/18

[#357637] Re: strings combine — Roger Pack <rogerpack2005@...> 2010/02/18

[#357658] Re: strings combine — Robert Klemme <shortcutter@...> 2010/02/19

On 02/18/2010 11:32 PM, Roger Pack wrote:

[#357681] Re: strings combine — Raul Jara <raul.c.jara@...> 2010/02/19

This doesn't work if you assign the strings to variables though:

[#357683] Re: strings combine — Robert Klemme <shortcutter@...> 2010/02/19

2010/2/19 Raul Jara <raul.c.jara@gmail.com>:

[#357697] Re: strings combine — Raul Jara <raul.c.jara@...> 2010/02/19

Robert Klemme wrote:

[#357707] Re: strings combine — Robert Klemme <shortcutter@...> 2010/02/19

On 19.02.2010 17:40, Raul Jara wrote:

[#357716] Re: strings combine — Raul Jara <raul.c.jara@...> 2010/02/19

> Robert@babelfish ~

[#357621] RTranslate Gem (Open-URI) and Encoding — The Chromag <brent@...>

I'm using the rtranslate gem (sishen-rtranslate) to handle translating

12 messages 2010/02/18

[#357622] Ruby conditionals subtlety? — Farhad Farzaneh <ff@...>

Hi,

18 messages 2010/02/18
[#357630] Re: Ruby conditionals subtlety? — Ryan Davis <ryand-ruby@...> 2010/02/18

[#357632] Re: Ruby conditionals subtlety? — Farhad Farzaneh <ff@...> 2010/02/18

Ryan Davis wrote:

[#357641] Re: Ruby conditionals subtlety? — Ryan Davis <ryand-ruby@...> 2010/02/18

[#357642] Re: Ruby conditionals subtlety? — Farhad Farzaneh <ff@...> 2010/02/19

Ryan Davis wrote:

[#357678] Get Goolge Result — Sajjad Seyyed <treep_ir@...>

Hi

15 messages 2010/02/19

[#357872] Ruby Idiom To Retry open() Upto N Times Before Giving Up — Dan <dandiebolt@...>

I write a lot of scripts that I run once or infrequently that uses open-rui. Occasionally I run into a web site that times out or is unavailable for a period of time. My normal solution is to just rerun the script manually at a later time and the problem goes away. What I would like to start doing is rescuing the open() and retrying the open() after a delay. What would be the most idiomatic way to try opening a url say n times before giving up? Here is my crude code for trying twice:

8 messages 2010/02/22

[#357878] Speed sprint — Benedikt Müller <benemue@...>

Hi

23 messages 2010/02/22

[#357899] Test::Unit Newbie Question regarding loops — Yotta Meter <spam@...>

With the following example:

13 messages 2010/02/23
[#357936] Re: Test::Unit Newbie Question regarding loops — Brian Candler <b.candler@...> 2010/02/23

Yotta Meter wrote:

[#357939] Re: Test::Unit Newbie Question regarding loops — Yotta Meter <spam@...> 2010/02/23

This is really the great idea I was looking for, thanks. Obviously I'm

[#357940] How do I set the encoding on a regexp ? — Perry Smith <pedzsan@...>

Title pretty much says it all. Here is a small sample program:

20 messages 2010/02/23
[#358010] Re: How do I set the encoding on a regexp ? — David Springer <dnspringer@...> 2010/02/24

Perry,

[#358060] Array index question — John Smith <ks1911shooter@...>

Question about an array. Say I have the following array...

12 messages 2010/02/25

[#358108] Installing Pg gem for PostGreSQL 8.4 — Saeed Bhuta <saeed.bhuta@...>

Hi All,

35 messages 2010/02/26
[#358114] Re: Installing Pg gem for PostGreSQL 8.4 — Shashank Tiwari <tshanky@...> 2010/02/26

Are you installing this on a mac, windows or a linux environment? You may

[#358116] Re: Installing Pg gem for PostGreSQL 8.4 — Saeed Bhuta <saeed.bhuta@...> 2010/02/26

Shashank Tiwari wrote:

[#358256] Re: Installing Pg gem for PostGreSQL 8.4 — Saeed Bhuta <saeed.bhuta@...> 2010/03/01

Saeed Bhuta wrote:

[#358269] Re: Installing Pg gem for PostGreSQL 8.4 — Reid Thompson <reid.thompson@...> 2010/03/01

On Mon, 2010-03-01 at 17:56 +0900, Saeed Bhuta wrote:

[#358278] Re: Installing Pg gem for PostGreSQL 8.4 — Saeed Bhuta <saeed.bhuta@...> 2010/03/01

Here is the result of the '$ dpkg --get-selections' command;

[#358288] Re: Installing Pg gem for PostGreSQL 8.4 — Reid Thompson <reid.thompson@...> 2010/03/01

On Mon, 2010-03-01 at 23:19 +0900, Saeed Bhuta wrote:

[#358289] Re: Installing Pg gem for PostGreSQL 8.4 — Saeed Bhuta <saeed.bhuta@...> 2010/03/01

Reid Thompson wrote:

[#358330] Re: Installing Pg gem for PostGreSQL 8.4 — Reid Thompson <reid.thompson@...> 2010/03/01

On Tue, 2010-03-02 at 00:58 +0900, Saeed Bhuta wrote:

[#358370] Re: Installing Pg gem for PostGreSQL 8.4 — Saeed Bhuta <saeed.bhuta@...> 2010/03/02

Reid Thompson wrote:

[#358386] Re: Installing Pg gem for PostGreSQL 8.4 — Reid Thompson <reid.thompson@...> 2010/03/02

On Tue, 2010-03-02 at 17:24 +0900, Saeed Bhuta wrote:

[#358387] Re: Installing Pg gem for PostGreSQL 8.4 — Saeed Bhuta <saeed.bhuta@...> 2010/03/02

Reid Thompson wrote:

[#358399] Re: Installing Pg gem for PostGreSQL 8.4 — Reid Thompson <reid.thompson@...> 2010/03/02

On Tue, 2010-03-02 at 23:09 +0900, Saeed Bhuta wrote:

[#358402] Re: Installing Pg gem for PostGreSQL 8.4 — Reid Thompson <reid.thompson@...> 2010/03/02

On Tue, 2010-03-02 at 11:23 -0500, Reid Thompson wrote:

[#358117] Music Theory (#229) — Daniel Moore <yahivin@...>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

29 messages 2010/02/26
[#358430] Re: Music Theory (#229) — Ben Rho <dearbenj@...> 2010/03/03

Daniel X Moore wrote:

[#358444] Re: Music Theory (#229) — Daniel Moore <yahivin@...> 2010/03/03

Wow, this is some great discussion! Both piano and guitar chords are

[#358467] Re: Music Theory (#229) — Ben Rho <dearbenj@...> 2010/03/03

Daniel X Moore wrote:

[#358141] running a file — John Pasqa <jasello098@...>

ok, i'm writing a ruby program that interprets some text and does stuff

14 messages 2010/02/27

[#358204] Shoes? — Kurtis Rainbolt-greene <thinkwritemute@...>

Ok, so I'm getting back into GUI development and I want to use Ruby.

23 messages 2010/02/28
[#358205] Re: Shoes? — Howard Roberts <howardroberts@...> 2010/02/28

Kurtis Rainbolt-greene wrote:

[#358208] Re: Shoes? — Kurtis Rainbolt-greene <thinkwritemute@...> 2010/02/28

Howard Roberts wrote:

[#358228] Re: Shoes? — Ryan Davis <ryand-ruby@...> 2010/02/28

eval and implicit passing of blocks

From: Peter McLain <peter.mclain@...>
Date: 2010-02-05 18:04:32 UTC
List: ruby-talk #356659
Hi,

   I'm trying to understand if/how/when/why Ruby implicitly passes  
blocks to
   instance_eval, class_eval and eval, but not to plain methods.

   It seems that 1.9 behavior is consistent across all versions of  
eval: a
   block, passed into a method that does an eval, is available for use  
by
   that eval.  It also seems that 1.8.x has a bug in that the first  
level
   method called does not make the block available to eval, but that
   it is available to more deeply nested method calls.

       class Mystery1
         def level_1(&block)
           level_2(&block)

           # 1.8.x: LocalJumpError ;  1.9.x: Ok
           puts "Mystery1 level_1: #{instance_eval('yield')}"
         end

         def level_2(&block)
           level_3(&block)
           puts "Mystery1 level_2: #{instance_eval('yield')}" # OK
         end

         def level_3(&block)
           puts "Mystery1 level_3: #{instance_eval('yield')}" # OK
         end
       end

       o = Mystery1.new
       begin
         o.level_1 { 12 }
       rescue Exception => e
         puts "#{o.class} raised #{e.class}: #{e.message}"
         p e.backtrace
       end

   Running this against 1.8.[67] and 1.9.2 gives different results:

       ruby-1.8.6-tv1_8_6_398: ruby 1.8.6 (2010-02-04 patchlevel 398)  
[i686-darwin9.8.0]

       Mystery1 level_3: 12
       Mystery1 level_2: 12
       Mystery1 raised LocalJumpError: (eval):1:in `level_1': no block  
given
       ["/Users/pmclain/tmp/m1.rb:6:in `level_1'", "/Users/pmclain/tmp/ 
m1.rb:21"]

       ruby-1.8.7-p249: ruby 1.8.7 (2010-01-10 patchlevel 249) [i686- 
darwin9.8.0]

       Mystery1 level_3: 12
       Mystery1 level_2: 12
       Mystery1 raised LocalJumpError: (eval):1:in `level_1': no block  
given
       ["/Users/pmclain/tmp/m1.rb:6:in `level_1'", "/Users/pmclain/tmp/ 
m1.rb:21"]

       ruby-1.9.2-tv1_9_2_preview2: ruby 1.9.2dev (2009-09-07 trunk  
24787) [i386-darwin9.8.0]

       Mystery1 level_3: 12
       Mystery1 level_2: 12
       Mystery1 level_1: 12

   Question 1: Is the 1.8 behavior a bug?

   Question 2: Is the 1.9 behavior intended?  If so, is it documented
   anywhere? Perhaps the various eval methods should document that  
they pass
   the calling frame's block to the eval.

   If I replace "instance_eval" with "Mystery1.class_eval", I get the  
same
   result.  If I replace "instance_eval" with "eval", I get different
   results:

       ruby-1.8.6-tv1_8_6_398: ruby 1.8.6 (2010-02-04 patchlevel 398)  
[i686-darwin9.8.0]

       Mystery1 raised LocalJumpError: (eval):1:in `level_3': no block  
given
       ["/Users/pmclain/tmp/m1.rb:15:in `level_3'", "/Users/pmclain/ 
tmp/m1.rb:10:in `eval'", "/Users/pmclain/tmp/m1.rb:15:in `level_3'", "/ 
Users/pmclain/tmp/m1.rb:10:in `level_2'", "/Users/pmclain/tmp/m1.rb: 
3:in `level_1'", "/Users/pmclain/tmp/m1.rb:21"]

       ruby-1.8.7-p249: ruby 1.8.7 (2010-01-10 patchlevel 249) [i686- 
darwin9.8.0]

       Mystery1 raised LocalJumpError: (eval):1:in `level_3': no block  
given
       ["/Users/pmclain/tmp/m1.rb:15:in `level_3'", "/Users/pmclain/ 
tmp/m1.rb:10:in `eval'", "/Users/pmclain/tmp/m1.rb:15:in `level_3'", "/ 
Users/pmclain/tmp/m1.rb:10:in `level_2'", "/Users/pmclain/tmp/m1.rb: 
3:in `level_1'", "/Users/pmclain/tmp/m1.rb:21"]

       ruby-1.9.2-tv1_9_2_preview2: ruby 1.9.2dev (2009-09-07 trunk  
24787) [i386-darwin9.8.0]

       Mystery1 level_3: 12
       Mystery1 level_2: 12
       Mystery1 level_1: 12

   So it looks like 1.9 is consistent in making the block available to  
eval
   at all levels, but 1.8 treats eval differently than class_eval and
   instance_eval.

   It also looks like 1.8 has another bug in that it tries too hard to
   pass blocks along, whereas 1.9 gives reasonable behavior.  In  
Mystery2 I
   don't pass the block from level_2 to level_3, and 1.9 complains  
that no
   block was given; 1.8 seems to pass the block implicitly...

       class Mystery2
         def level_1(&block)
           level_2(&block)

           # 1.8.x: LocalJumpError ;  1.9.x: Ok
           #puts "Mystery2 level_1: #{instance_eval('yield')}"
         end

         def level_2(&block)
           level_3
           puts "Mystery2 level_2: #{instance_eval('yield')}" # OK
         end

         def level_3
           puts "Mystery2 level_3: #{instance_eval('yield')}" # 1.8:  
OK  1.9: LocalJumpError
         end
       end

       o = Mystery2.new
       begin
         o.level_1 { 12 }
       rescue Exception => e
         puts "#{o.class} raised #{e.class}: #{e.message}"
         p e.backtrace
       end

   And the output:

       ruby-1.8.6-tv1_8_6_398: ruby 1.8.6 (2010-02-04 patchlevel 398)  
[i686-darwin9.8.0]

       Mystery2 level_3: 12
       Mystery2 level_2: 12

       ruby-1.8.7-p249: ruby 1.8.7 (2010-01-10 patchlevel 249) [i686- 
darwin9.8.0]

       Mystery2 level_3: 12
       Mystery2 level_2: 12

       ruby-1.9.2-tv1_9_2_preview2: ruby 1.9.2dev (2009-09-07 trunk  
24787) [i386-darwin9.8.0]

       Mystery2 raised LocalJumpError: no block given (yield)
       ["/Users/pmclain/tmp/m2.rb:15:in `instance_eval'", "/Users/ 
pmclain/tmp/m2.rb:15:in `instance_eval'", "/Users/pmclain/tmp/m2.rb: 
15:in `level_3'", "/Users/pmclain/tmp/m2.rb:10:in `level_2'", "/Users/ 
pmclain/tmp/m2.rb:3:in `level_1'", "/Users/pmclain/tmp/m2.rb:21:in  
`<main>'"]


   Question 3: Is the 1.8 behavior a bug?
   Question 4: Is the 1.9 behavior correct?

   Is there any documentation (other than the code) that describes  
this in
   detail?  Neither the Pick Axe book, nor the Flanagan/Matz book give
   detail on this.  The RubySpecs also seem silent on this.


--  
Peter McLain
peter.mclain@gemstone.com




In This Thread

Prev Next