Re: Bug or feature

2012-09-18 Thread Robert Klemme
On Wed, Sep 19, 2012 at 8:00 AM, Damjan Rems wrote: > So there is a good reason not to implement object duplication (deep > cloning). Results may be unpredictable so better don't do it. As I said elsewhere: I prefer custom logic tailored to the use case and not a general mechanism which simply d

Re: Overriding Object#clone vs. Overriding Object#dup for Deep-Cloning

2012-09-18 Thread Robert Klemme
On Tue, Sep 18, 2012 at 9:20 PM, Yaser Sulaiman wrote: > Hi. > > Is there a community convention that specifies which of the two methods, > `Object#clone` and `Object#dup`, should be overridden for the purposes of > deep-cloning? > > On Stackoverflow, some say that `clone` should be overridden [1]

Re: Bug or feature

2012-09-18 Thread Robert Klemme
On Tue, Sep 18, 2012 at 8:44 PM, Damjan Rems wrote: > Robert Klemme wrote in post #1076432: > >> For full object tree copy you can do >> >> irb(main):007:0> c = Marshal.load(Marshal.dump(a)) > > Why is real cloning not implemented in ruby, since this fake cloning can > lead to a lot of troubles.

Re: Bug or feature

2012-09-18 Thread Robert Klemme
On Tue, Sep 18, 2012 at 12:19 PM, Hans Mackowiak wrote: > when you only have a flat array, you could do: > b = a.map(&:clone) > > but beware, some objects like fixnumbers dont want to be cloned Well, you can do b = a.map {|x| x.clone rescue x} But that is still not a deep copy - unless types of

Re: Ruby Postgres driver (pg) and case sensitivity

2012-09-18 Thread Robert Klemme
On Tue, Sep 18, 2012 at 1:47 PM, Thomas Bednarz wrote: > Well the postgres server is not the problem, I use pgAdmin with its ISQL > to execute statements and there case doesn't matter either. I know. I used psql to illustrate the point about case handling because I assume that it might be simila

Re: Bug or feature

2012-09-18 Thread Robert Klemme
On Tue, Sep 18, 2012 at 9:36 AM, Damjan Rems wrote: > There has probably been some discussion about this problem so sorry if I > am repeating but it is so crucial that should be mention every once in a > while. > > This simple example: > > a=['0'] > 1.upto(2) do > b = a.clone > c = a.clone >

Re: Ruby Postgres driver (pg) and case sensitivity

2012-09-18 Thread Robert Klemme
On Tue, Sep 18, 2012 at 9:02 AM, Thomas Bednarz wrote: > I am playing around with ruby and postgres. Postgresql is usually cAsE > SenSiTive. When I create a prepared statement in ruby like > > conn = PGconn.open(.) > conn.prepare('stmt1', 'insert into MyTable(my_number, my_string) > values($1,