[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

10 things to be aware of in 1.8 -> 1.9 transition

David A. Black

1/14/2009 6:41:00 PM

Hi --

I know it's not usual to announce blog posts here, but I'm going to
indulge the impulse as the content of this one is something I might
have posted here anyway:

http://dablog.rubypal.com/2009/1/14/10-things-to-be-aware-of-in-moving-t...

I'm finishing up "The Well-Grounded Rubyist" and am thinking of
writing an appendix with more or less this content, so I thought I'd
run it up the flagpole first.


David

--
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.r...
Coming in 2009: The Well-Grounded Rubyist (http://manning....)

http://www.wis... => Independent, social wishlist management!

21 Answers

Joel VanderWerf

1/14/2009 7:12:00 PM

0

David A. Black wrote:
> Hi --
>
> I know it's not usual to announce blog posts here, but I'm going to
> indulge the impulse as the content of this one is something I might
> have posted here anyway:
>
> http://dablog.rubypal.com/2009/1/14/10-things-to-be-aware-of-in-moving-t...
>
>
> I'm finishing up "The Well-Grounded Rubyist" and am thinking of
> writing an appendix with more or less this content, so I thought I'd
> run it up the flagpole first.
>
>
> David
>

I do appreciate it, having been slow to test on 1.9.

There is a small bug in the text though:

x = 1
{|x| }

Maybe there should be an "x=3" in the block?

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

James Gray

1/14/2009 7:14:00 PM

0

On Jan 14, 2009, at 12:40 PM, David A. Black wrote:

> Hi --
>
> I know it's not usual to announce blog posts here, but I'm going to
> indulge the impulse as the content of this one is something I might
> have posted here anyway:
>
> =
http://dablog.rubypal.com/2009/1/14/10-things-to-be-aware-of-in-m...
ruby-1-9
>
> I'm finishing up "The Well-Grounded Rubyist" and am thinking of
> writing an appendix with more or less this content, so I thought I'd
> run it up the flagpole first.

Double-check your examples in "Block variables scope." It looks like =20=

they may be cut off.

I also think you need to add a section on this error, which seems very =20=

likely to be the first thing programmers encounter in the new m17n code:

$ echo "R=E9sum=E9" > utf8.rb
$ ruby_dev utf8.rb
utf8.rb:1: invalid multibyte char (US-ASCII)

I love the idea overall though. Thanks for sharing!

James Edward Gray II=

David A. Black

1/14/2009 7:23:00 PM

0

Hi --

Sigh -- I forgot to wrap some of them in <pre>.

Everyone please look at it again for those block examples :-)


David


On Thu, 15 Jan 2009, Joel VanderWerf wrote:

> David A. Black wrote:
>> Hi --
>>
>> I know it's not usual to announce blog posts here, but I'm going to
>> indulge the impulse as the content of this one is something I might
>> have posted here anyway:
>>
>> http://dablog.rubypal.com/2009/1/14/10-things-to-be-aware-of-in-moving-t...
>>
>> I'm finishing up "The Well-Grounded Rubyist" and am thinking of
>> writing an appendix with more or less this content, so I thought I'd
>> run it up the flagpole first.
>>
>>
>> David
>>
>
> I do appreciate it, having been slow to test on 1.9.
>
> There is a small bug in the text though:
>
> x = 1
> {|x| }
>
> Maybe there should be an "x=3" in the block?
>
> --
> vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
>

--
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.r...
Coming in 2009: The Well-Grounded Rubyist (http://manning....)

http://www.wis... => Independent, social wishlist management!

F. Senault

1/14/2009 7:34:00 PM

0

Le 14 janvier 2009 à 20:14, James Gray a écrit :

> I also think you need to add a section on this error, which seems very
> likely to be the first thing programmers encounter in the new m17n code:

Oh yeah.

And this :

>> require "yaml"
=> true
>> a = "héhé"
=> "héhé"
>> b = a.to_yaml
=> "--- !binary |\naMOpaMOp\n\n"
>> c = YAML.load(b)
=> "h\xC3\xA9h\xC3\xA9"
>> c << "héhé"
Encoding::CompatibilityError: incompatible character encodings:
ASCII-8BIT and UTF-8
from (irb):8
from /usr/local/bin/irb:12:in `<main>'

Fred
Who is still having trouble with utf-8 in one of his rails models...
--
Aleph-null bottles of beer on the wall, aleph-null bottles of beer.
Take one down and pass it around,
Aleph-null bottles of beer on the wall... (Ingvar the Grey in the SDM)

Robert Dober

1/14/2009 8:00:00 PM

0

On Wed, Jan 14, 2009 at 7:40 PM, David A. Black <dblack@rubypal.com> wrote:
> Hi --
>
> I know it's not usual to announce blog posts here, but I'm going to
> indulge the impulse as the content of this one is something I might
> have posted here anyway:
>
I believe this is something lots of folks want desperately, YHS included.
So please keep the good work up.
A small comment on hash key ordering:
As you said it is insertion order, not update order, thus in the
(unlikely) case that one wants to change that, one
has to delete the key.
h = { a: 42, b: 42 }
h.update a: 42
h --> { a: 42, b: 42 }
vs.
h.delete a:
h.update a: 42
h --> { b: 42, a: 42 }

It seems to be true too that the hash literal is insertion order
preserving, thus the read syntax and write
syntax for hashes seem identical :).
Can anybody confirm this please?
Cheers
R

--
It is change, continuing change, inevitable change, that is the
dominant factor in society today. No sensible decision can be made any
longer without taking into account not only the world as it is, but
the world as it will be ... ~ Isaac Asimov

Ollivier Robert

1/15/2009 10:02:00 AM

0

In article <1s9tj58uadsr2.dlg@tamnavulin.lacave.local>,
F. Senault <fred@lacave.net> wrote:
>> I also think you need to add a section on this error, which seems very
>> likely to be the first thing programmers encounter in the new m17n code:
>
>Oh yeah.

I agree, everything encoding-related will bite people. This is complicated in
1.9.
--
Ollivier ROBERT -=- CND/VIF/SQS -=-
Systems Quality Support

Brian Candler

1/15/2009 1:32:00 PM

0

Joel VanderWerf wrote:
> There is a small bug in the text though:
>
> x = 1
> {|x| }
>
> Maybe there should be an "x=3" in the block?

No, it's correct as it is. The point is that in ruby 1.8, |x| is
assigned to each time the block is called, and if x existed before the
block, it remains after the block as the last value. This is regardless
of whether you actually use or assign to x inside the block.

$ irb
irb(main):001:0> x = 1
=> 1
irb(main):002:0> [2,3].each{|x| }
=> [2, 3]
irb(main):003:0> x
=> 3

But in ruby1.9, |x| is a local block argument, independent of any local
variable x outside the block.

$ irb19
irb(main):001:0> x = 1
=> 1
irb(main):002:0> [2,3].each{|x| }
=> [2, 3]
irb(main):003:0> x
=> 1
--
Posted via http://www.ruby-....

James Gray

1/15/2009 1:42:00 PM

0

On Jan 15, 2009, at 5:18 AM, Michal Suchanek wrote:

> 2009/1/14 James Gray <james@grayproductions.net>:
>> On Jan 14, 2009, at 12:40 PM, David A. Black wrote:
>>
>>> Hi --
>>>
>>> I know it's not usual to announce blog posts here, but I'm going to
>>> indulge the impulse as the content of this one is something I might
>>> have posted here anyway:
>>>
>>>
>>> =
http://dablog.rubypal.com/2009/1/14/10-things-to-be-aware-of-in-m...
ruby-1-9
>>>
>>> I'm finishing up "The Well-Grounded Rubyist" and am thinking of
>>> writing an appendix with more or less this content, so I thought I'd
>>> run it up the flagpole first.
>>
>> Double-check your examples in "Block variables scope." It looks =20
>> like they
>> may be cut off.
>>
>> I also think you need to add a section on this error, which seems =20
>> very
>> likely to be the first thing programmers encounter in the new m17n =20=

>> code:
>>
>> $ echo "R=E9sum=E9" > utf8.rb
>> $ ruby_dev utf8.rb
>> utf8.rb:1: invalid multibyte char (US-ASCII)
>>
>
> As a quick fix you can do
>
> $ ruby -KU utf8.rb
>
> but a guide summarizing the encoding features and possible problems
> would be very helpful.

Yeah, I've been working on such a guide:

http://blog.grayproductions.net/articles/understa...

I just haven't got to the 1.9 sections yet. I will eventually though=85

James Edward Gray II=

Michael Fellinger

1/15/2009 3:42:00 PM

0

On Thu, Jan 15, 2009 at 3:40 AM, David A. Black <dblack@rubypal.com> wrote:
> Hi --
>
> I know it's not usual to announce blog posts here, but I'm going to
> indulge the impulse as the content of this one is something I might
> have posted here anyway:
>
> http://dablog.rubypal.com/2009/1/14/10-things-to-be-aware-of-in-moving-t...
>
> I'm finishing up "The Well-Grounded Rubyist" and am thinking of
> writing an appendix with more or less this content, so I thought I'd
> run it up the flagpole first.

You might also want to mention (around the point of block-parameters
have def syntax) that procs can take a block now.
The Enumerator stuff is in 1.8.7 already, not sure if it's that
notable. Maybe some things instead about String (#each, Enumerable,
[0], ?a, ...) would be more helpful.

^ manveru

David A. Black

1/15/2009 3:52:00 PM

0

Hi --

On Fri, 16 Jan 2009, Michael Fellinger wrote:

> On Thu, Jan 15, 2009 at 3:40 AM, David A. Black <dblack@rubypal.com> wrote:
>> Hi --
>>
>> I know it's not usual to announce blog posts here, but I'm going to
>> indulge the impulse as the content of this one is something I might
>> have posted here anyway:
>>
>> http://dablog.rubypal.com/2009/1/14/10-things-to-be-aware-of-in-moving-t...
>>
>> I'm finishing up "The Well-Grounded Rubyist" and am thinking of
>> writing an appendix with more or less this content, so I thought I'd
>> run it up the flagpole first.
>
> You might also want to mention (around the point of block-parameters
> have def syntax) that procs can take a block now.
> The Enumerator stuff is in 1.8.7 already, not sure if it's that
> notable. Maybe some things instead about String (#each, Enumerable,
> [0], ?a, ...) would be more helpful.

I'm not really dealing with 1.8.7 in my book (nor much in general).
[0] is a good idea. I do mention in my list that strings aren't
enumerable any more.


David

--
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.r...
Coming in 2009: The Well-Grounded Rubyist (http://manning....)

http://www.wis... => Independent, social wishlist management!