From: Devin Mullins Date: 2005-10-03T11:23:46+09:00 Subject: Re: C++ equivs in Ruby David A. Black wrote: >>> x = 123 >>> >>> x holds the immediate value 123, rather than a reference to it, which >>> is the rationale Matz has always given for not having x++ (i.e., it >>> would be equivalent to doing 123++ and that would make no sense). >> >> I don't think that's sufficient, else x += 1 would be equivalent to >> 123 += 1. > > Not necessarily. There's no cause and effect link here; each thing is > decided by Matz. I was talking about my impression over the years of > Matz's rationale. No, I meant the rationale in the above paragraph wasn't sufficient to draw the conclusion that ++ made no sense, as my counter-example showed. I realize that Matz has final say, and I also don't really care about the lack of a ++, so I wasn't trying to argue for it. > neither possibility (the variable str being reassigned, or having ++ > be a succ! equivalent) would really fit. You know what I'd really like? A "x .= :succ" notation. I know it's, like, totally counter to established Ruby semantics, but it'd save, like, (variable_name.size - 2) characters. Sample implementation in Ruby, for the * operator: require 'enumerator' ObjectSpace.enum_for(:each_object).find_all { |klazz| Class === klazz and klazz.instance_methods.include?("*") || klazz == Object }.each do |klazz| p klazz klazz.class_eval do def *(*a); send(*a) end end end (I'm not recommending that "." be overrideable, just that .= be some builtin shortcut. Actually, I'm not really recommending it. Just an extended joke.) Devin