From: Markus Date: 2004-10-15T02:21:55+09:00 Subject: Re: Ruby Directions (was Re: quality of error messages) On Thu, 2004-10-14 at 04:59, Robert Klemme wrote: > "Markus" schrieb im Newsbeitrag > news:1097683458.21256.95.camel@lapdog.reality.com... > > On Wed, 2004-10-13 at 02:19, Robert Klemme wrote: > > > "Markus" schrieb im Newsbeitrag > > > > > > > > > > still... for coding, i love slice! / gsub! etc. they are > > > > > amazingly useful constructs. i can't imagine living without > > > > > them :) > > > > > > > > The odd thing is, all you are generally getting with them is a > bit > > > > of syntactic sugar. Consider the relationship between: > > > > > > > > s = gsub(p,v) > > > > s.gsub!(p,v) > > > > > > > > i = i + k > > > > i += k > > > > > > It's not only sugar. It's different semantics and different > performance > > > (see the other post with the benchmark). There are enough > circumstances > > > where you don't know whether someone else still holds a reference to > an > > > instance at hand. As an example, that's the reason why Strings when > used > > > as Hash keys are duped and frozen if they are not yet frozen. > > > > > > Kind regards > > > > > > robert > > > > > > > In your previous response to this same post you at least included > > the rest of my statement: > > > > > Unless you have lent a friend a reference to s and are using it to > > > send secret messages, you aren't really depending on the mutability > > > of strings so much as the modifability of variables. > > > > In my response I further clarified my point, that most users of > > gusb! use it not because they want the modification to affect some other > > reference to the same string, but simply as a shorthand. Instead of > > trying yet again, to clarify a point that we both obviously understand, > > I will address a more interesting point: > > > > Why do you keep taking my remarks out of context to "rebut" them? > > > > -- Markus > > I don't consider the difference between "s.gsub!(...)" and "s = > s.gsub(...)" syntactic sugar - even in cases where one thinks or knows > that the reference was not leaked. So although some bit of context was > missing there was no distortion since I disagree with the syntactic sugar > thesis for *all* cases. > > Sadly enough, I get the feeling we're talking across each other. I regret > that. So do I. I'm willing to try to correct the problem if you are. I did not saying that "it is only syntactic sugar" and certainly not "for *all* cases" which seems to be the point with which you are disagreeing. I said that, in most cases "all the programmer was getting out of it" was syntactic sugar*; in other words, that although there are semantic differences most of the code written using gsub! (note: "most", not "all") does not rely on them. It was a minor point, perhaps, but I thought it was interesting in the (now long lost) original context. -- Markus * And, as I previously conceded, some performance advantage--though I still maintain that distinguishing two forms that are semantically equivalent for your purposes based on presumed/measured performance differences is not wise in the long run.