From: Mathieu Bouchard Date: 2005-03-22T09:49:36+09:00 Subject: Re: strip and its evil brother strip! On Mon, 21 Mar 2005, Csaba Henk wrote: > On 2005-03-20, Mathieu Bouchard wrote: > There _is_ equivalent of this in ruby, it's just it's not sugared: > x.instance_eval { chop; strip } > But you can see that this form makes difference semantically: without it > you should do > s = "ab#{foo}de"[1..3] > s.chop! > s.strip! > The above form saves you that local assignment: > "ab#{foo}de"[1..3].instance_eval { chop!; strip! } The problem with it, compared to the smalltalk one, is that it changes the scope of instance-variables. > It's a very useful method, and I think only its ugly lengthy names > keeps it away from becoming one of the most basic rubyisms. I often use "i" as an abbreviation for instance. I write "ivar" instead of "instance variable". Even the C/Ruby API calls them that way. However, the subtext of such a phrase annoys me. It suggests a binary opposition that asserts the supremacy of the classes over other objects, and effectively even ejects the name "object" in favour of some statement of dependency (it's always about being an instance _of_ something). I'd rather have them called "object variables" or "ovar" but if not then i can accept "ivar" as long as i don't de-abbreviate it. (yes, i'm slightly exaggerating, but this should show that Ruby is much closer to class-based OOP than to prototype-based OOP.) More important than the above, though, is the fact that in instance_methods and instance_variables, the meaning of "instance" is confusing: in one, you're looking at things that belong to a class but applies to its instances, and in the latter case, you're looking at things that belong to a single object and applies only to itself, and per se have nothing at all to do with classes and instantiation, beyond the fact that most of those variables get set up during instantiation, but simply by convention and not by necessity. > It's not even some weirdo which is justified to have weird name > because of its weirdness. Weirdness is in the eye of the beholder... you see, some people have learnt from the Church of JAVA (tm) that eval is evil and dirty (Ruby has eval), that multiple inheritance is evil (Ruby has it too), that classes are the centre of the world, that classes are and *have* to be the unit of program reusability, that writing "protected static final void" all over is normal, etc. Ruby has so many people with different experiences, and thus so different expectations of normalcy, given what they've been "raised with" when they started computer programming. (oh, and if you're not following my postmodernist reasonings, i'm sorry.) _____________________________________________________________________ Mathieu Bouchard -=- Montr�al QC Canada -=- http://artengine.ca/matju