Hi,

In message "[ruby-talk:5247] Re: Changes in 1.6.0"
    on 00/10/03, "Hal E. Fulton" <hfulton / austin.rr.com> writes:

|> = Changes in 1.6.0
|> * no to_a for multiple assignment (uses to_ary if available)
|
|I don't understand this at all.

In 1.4, multiple assignment

  a, b = c

invokes c.to_a internally if a is not an array.  1.6 multiple
assignment does not call to_a, but if c has to_ary method, invoke it
to convert c into an array.

|> * rescue => variable
|> * rescue modifier
|> * rescue clause for method body
|
|May we see some examples?

 rescue => variable

  begin
    ...
  rescue StandardError => err
    p err.message
  end

 rescue modifier

  f.print 25, "\n" rescue p "output failed"

 rescue clause for method body

  def foo
    ...
  rescue LoadError
    STDERR.print "can't load\n"
  end

|> * syntax enhanced, e.g.
|>
|>   a,b = File::split "foo/bar"
|
|I see that this doesn't work in my 1.4.3 -- I thought this would have
|worked long ago.

Have you tried?  I found it was not working.  So I fixed it in 1.6.

|>   a = yield b
|
|Meaning that the block can return a value? Does it use a return statement or
|is it
|optional? Or am I missing the point?

No, yield has the evaluated value of the block, which is the value
from last evaluated expression in the block.

|>   [File::dirname "foo/bar"]
|
|What does this mean? Isn't it an array without the brackets? Or is this an
|array within an array?

This equals

   [File::dirname("foo/bar")]  #=> [["foo","bar"]]

|> * singleton method for nil,true,false
|
|???

  def nil.foo
    print "foo\n"
  end
  nil.foo

|>   no singleton method for Fixnums and Symbols yet
|
|Meaning what? And what is a Symbol?

  def 1.foo
    print "1\n"
  end
  1.foo

is not possible (yet).  Symbol is the object corresponding identifier
such as :Symbol, :+, etc.  In 1.4, :Symbol etc. was Fixnums.  1.6 has
specialized class for the purpose.

|> * built-in 'final'
|
|???

The functionality provided by standard library 'final' is now built
into the core.

|> * new regex \G (?>...)
|
|???

\G matches at the end-of-match position of prior match.  It is only
useful in sequential match like gsub/scan.

(?>...) is independent subexpression, one which matches the substring
that a I<standalone> C<pattern> would match if anchored at the given
position, and it matches nothing other than this substring.  

See perlre.pod for detail.

|> * regex does not support  \< and \> offically
|
|???

It used to support \< (beginning of word) and \> (end of word),
inherited from Emacs regex.  But it's no longer supported, because it
contradict with the principle of "backslashed metacharacter" -- all
alphanumeric metacharacters should be prefixed by backslashes, and all
non-alphanumeric metacharacters should NOT be prefixed by backslashes.

|> * regex option /p renamed to /m
|
|Why?

I chose /p to stand for POSIX, but I was misinformed.  /p behavior was
not related to POSIX at all.  So I changed that to /m (multiline).

|> * compile time string concatenation
|
|Example?

  a = "this is an example of " "compile " "time string" "concatenation"

|> * Integer#modulo
|> * consistent %, divmod
|
|OK, this was discussed at MUCH length a few months ago...
|what is the end result? Can we summarize this, and is it
|consistent with other languages or not?

In summary:

  * divmod returns the result of integer division and modulo (%)
  * % and module have same behavior
  * % behavior is consistent with Python and C99
  * modulo and remainder are consistent with Scheme equivalent
    respectively.

I'm not good at mathematic.  So somebody else can explain in detail.

|> * nil as valid Hash value
|
|Hmm... so we can't compare against nil to find if a value is
|not there?

Basically.  You can use either

  a) Hash#key? to check if the key exists.
  b) Hash#fetch(key) which raises an exception for non existing key. 
  c) Hash#fetch(key, ifnone) which returns the value of ifnone for non
     existing key.
  d) Hash#fetch(key){...} which evaluate the block for non exisiting
     key.
  e) make should you don't use nil as a value, and continue to
     compare against nil to check if the key exists.  But still
     remember you can't remove the value by assigning the value to
     nil.  OK?

I hope this helps.
							matz.