From: matz@... (Yukihiro Matsumoto) Date: 2000-03-19T01:23:24+09:00 Subject: [ruby-talk:02010] Re: Ruby Syntax similar to other languages? Hi, In message "[ruby-talk:02003] Re: Ruby Syntax similar to other languages?" on 00/03/18, "Conrad Schneiker" writes: |> What's the benefit of foo.s(/pat/, "repl", "g") over foo.gsub(/pat/, |"repl")? | |In vi, sed, and perl, you don't thing of sub and gsub as being two different |methods, but rather as a single method that is modulated by optional |parameters--including g, i, s, m, o, e, and x in perl (IIRC), which I |wouldn't want to see replaced by individual methods, since I (currently) |think it is much more natural to regard all of these things as variations on |a common theme. Hmm, although I think options i, s, m, o, and x should belong to regexp, I can understand your opinion. |Since I also use vi (actually gvim, a vastly improved GUI-based extension of |vi) all the time and have used perl a lot in the past, "s" seems like the |simplest and most natural name for what also seems to be most naturally |regarded as a single method. Actually, since awk always seemed awkward to me |even before I discovered perl, maybe I should say that because I think "s" |this is a more natural way to think of substitution, I happened to like the |way that vi and perl do it. Hmm, are you proposing new syntax to do that? A method like Clemens suggested in [ruby-talk:01962] can be added relatively easily, but introducing syntax like s/RE/STR/ is another story, which I can hardly accept. matz.