From: Gary Wright Date: 2007-08-08T13:18:35+09:00 Subject: Re: Question - Passing parameters by reference On Aug 7, 2007, at 6:28 PM, dblack@rubypal.com wrote: > I'm thinking more about variables than literals, though, because > that's where the questions arise. It's easy to see that 1++ is > meaningless; but it's harder, I've found at least, to explain why: > > x = 1 > x++ > > wouldn't make sense, without recourse to explaining the immediate > presence of 1 in x. Take a look at this message from Matz: . I have to think about this a bit more, but it isn't clear to me why the concept of immediate values needs to be introduced in order to explain the problems with x++ in Ruby. It seems to me that the idea of immediate values is not something inherent in Ruby's semantics but instead is baggage that arrives with programmers (myself included) coming from other languages. We try to find a place for it in Ruby when it isn't really needed. > It's definitely not in the interest of pushing > implementation details into view; it's more a matter of accounting for > the semantics of the language and the behavior of its methods (things > like ++ and why one can't append to symbols). Do those examples really require the introduction of immediate values? Once you understand that there is a one-to-one mapping between Fixnum instances and a subset of the integers it is clear why you can't 'increment' a Fixnum instance. It is a nonsensical concept yet the concept of 'successor' is well-defined. Similarly once you understand that there is a one-to-one mapping between Symbol instances and their 'label' it is clear why you can't 'append' something to the label and still have the same symbol. The identity of a Symbol instance is inherently tied to its label and it is that isomorphism that makes Symbols useful. I'm not sure how much more juice we can squeeze out of this orange but looking back at this thread it seems that the OP was looking for a way to change the 'value' of a Fixnum method argument in the same way that the 'value' of a String method argument can be changed. Cue the immediate value discussion. Instead of using the immediate value abstraction though, the situation can be explained by correcting the erroneous assumption that fixnum objects are containers for an integer value that can be changed. There is an extra level of indirection in the string case that simply doesn't exist in the fixnum case. Gary Wright