From: Tony Arcieri Date: 2008-08-30T07:46:32+09:00 Subject: Re: Immutable Ruby On Fri, Aug 29, 2008 at 2:21 PM, Steven Parkes wrote: > > Sounds similar to what Tony's thinking about with Reia. > http://wiki.reia-lang.org/wiki/Main_Page Yep, thanks for mentioning it. > * No more #<< :( Reia doesn't support << for syntactic reasons (in Reia this designates the beginning of a "binary") but it will allow "mutation" of its pseudo-objects (Lists, Dicts, etc.) using a "magic rebinding" technique (not presently implemented). This does differ somewhat from Ruby's semantics. Consider the following in Ruby: >> a = b = [1,2,3] => [1, 2, 3] >> a << 4 => [1, 2, 3, 4] >> b => [1, 2, 3, 4] Here a and b reference the same Array, so when you mutate a the contents of b also change. However, in Reia (this example actually works from its current interactive interpreter): >> a = b = [1,2,3] => [1,2,3] >> a.push(4) => [1,2,3,4] >> b => [1,2,3] Reia allows rebinding by compiling to static single assignment form (currently in development). This decomposes places where variables are potentially rebound into single assignment by keeping track of versions of variables. When you a.push(4) in Reia, it (will eventually be able to) create a new version of the a variable which is bound to the new version of the list. However, the value of b does not change. Is this confusing? Hard to say. I personally don't find it confusing, but YMMV. > * No more Symbol vs. String!!! :) Immutable strings are somewhat different from symbols. Erlang has both (except it calls symbols "atoms"). Symbols work off of what's effectively a big global hash table. With immutable strings you can have several copies which are identical but still require O(n) comparisons and so forth. > Nor any ! method. I plan on carrying over the method! convention and semantics into Reia, FWIW. method? is coming along as well. That said I find it nice the "default" approach in Ruby is to not modify the receiver. -- Tony Arcieri medioh.com