[#1207] warning in ruby extension eats memory — Eugene Scripnik <Eugene.Scripnik@...>

This message was posted to ruby-talk, but I didn't get responce from

22 messages 2003/07/01
[#1208] Re: warning in ruby extension eats memory — ts <decoux@...> 2003/07/01

>>>>> "E" == Eugene Scripnik <Eugene.Scripnik@itgrp.net> writes:

[#1209] Re: warning in ruby extension eats memory — Eugene Scripnik <Eugene.Scripnik@...> 2003/07/02

ts wrote:

[#1210] Re: warning in ruby extension eats memory — ts <decoux@...> 2003/07/02

>>>>> "E" == Eugene Scripnik <Eugene.Scripnik@itgrp.net> writes:

[#1211] Re: warning in ruby extension eats memory — Eugene Scripnik <Eugene.Scripnik@...> 2003/07/04

ts wrote:

[#1212] Re: warning in ruby extension eats memory — ts <decoux@...> 2003/07/04

>>>>> "E" == Eugene Scripnik <Eugene.Scripnik@itgrp.net> writes:

[#1213] Re: warning in ruby extension eats memory — Eugene Scripnik <Eugene.Scripnik@...> 2003/07/04

ts wrote:

[#1214] Re: warning in ruby extension eats memory — ts <decoux@...> 2003/07/04

>>>>> "E" == Eugene Scripnik <Eugene.Scripnik@itgrp.net> writes:

[#1215] Re: warning in ruby extension eats memory — Eugene Scripnik <Eugene.Scripnik@...> 2003/07/04

ts wrote:

[#1237] FTP.new with block — Gavin Sinclair <gsinclair@...>

Hi,

22 messages 2003/07/19
[#1238] Re: [Patch] FTP.new with block — ts <decoux@...> 2003/07/19

>>>>> "G" == Gavin Sinclair <gsinclair@soyabean.com.au> writes:

[#1240] Re: [Patch] FTP.new with block — Mathieu Bouchard <matju@...> 2003/07/19

[#1297] Fix for Bug 1058 — Markus Walser <walser@...>

Hi,

16 messages 2003/07/25

Re: [Patch] FTP.new with block

From: Richard Zidlicky <rz@...68k.org>
Date: 2003-07-20 09:35:18 UTC
List: ruby-core #1250
On Sun, Jul 20, 2003 at 03:06:13AM +0900, Dave Thomas wrote:
> Mathieu Bouchard wrote:
> 
> >On Sat, 19 Jul 2003, ts wrote:
> >
> >>>>>>>"G" == Gavin Sinclair <gsinclair@soyabean.com.au> writes:
> >>
> >>G> FTP.new and FTP.open are like their File counterparts: they accept a
> >>G> block, pass in the ftp object, and ensure the FTP connection is closed
> >>G> at the end of (or premature exit from) the block.
> >>Why all persons think that File::new can take a block ?
> >
> >
> >That's psychological: when people have a lot of things to learn, they
> >(carefully or not) forget the pieces that they can reinvent on the fly.
> 
> 
> Perhaps it's an argument for having File.new take a block too...
> 

something more systematic is needed. So far only 2 widely used 
classes appear to evaluate blocks passed to new: Proc and Tk.
Furthermore Tk is somehwat confusing for the beginner because
it uses instance_eval or something completely different to eval
the block.

Currently this is a mess because many "new" methods will *silently*
ignore the block, also the inability to tell easilly if a block
is evaluated by yield, instance_eval or something completely
different is not so helpfull. To make things worse it is not
clear what, if anything is returned when a block is taken.

How to get it consistent? Leave the 2 widely used exceptions
to the rule (no block arg for new) some time to phase out and
use either a clear naming convention (eg new_wb instead of new)
or some enhanced syntax sugar to make sure blocks don't get
ignored/misinterpreted without signaling an error.

# extend Object with method new_wb requiring a block
class Object
  def new_wb(*args)
    if block_given?
      res=new(*args)
      yield res
    else
      raise SyntaxError, "new_wb method requires a block"
    end
    return res
  end
end

Richard

In This Thread