Re: Why do some methods names which replace the content in place doesn't have the "!" sign?



Gregory Seidman wrote:
On Tue, Mar 28, 2006 at 11:22:31PM +0900, Peter Hickman wrote:
} Michael Ulm wrote:
[...]
} >It would if you knew C++. This is actually one of the more useful
} >features of C++. If a method is declared 'const', the compiler ensures
} >that it does not modify the instance variables of the object (unless you
} >use really deep magic). This can be quite useful when debugging.
} } I program in C++ (and Java and Perl) but fail to see how a feature from } a statically typed language would provide any benefit to a dynamic } language such as Ruby. Without even trying to work out how you would } hope to graft it on. I have never wanted for such a feature in Ruby but } I have wanted features from Ruby in other languages.

There are many valuable features that are orthogonal to whether typing is
static or dynamic. One example is OO. The const-ness of an object is a
typing issue, but duck-typing is still typing. When I call a method on an
object, I am asking it to respond to a particular message with a particular
set of arguments (which are part of the definition of the message). If it
doesn't, it is not "a duck." If I ask an object to respond to a particular
message, and included in that message is an argument that is const, the
object is only "a duck" if it can accept and use that argument without
modifying it.

Fine. Firstly explain how having const methods in Ruby would enhance the language, that is to say how is would help do something in Ruby easier and safer than the current version of Ruby, then (for bonus points) explain how it could be implemented. Just because a feature exists in another language does not mean that it is /missing/ from Ruby. I like abstract methods in Java but I do not think that they are missing from Ruby and their absence has not caused me any problems. What makes a language a good language in my book is not a feature list of every conceivable paradigm but a clear underlying philosophy that is simple to grasp, this means that a good language will probably not have some features that are in other languages. Lua does not include integers! Imagine that, a language without integers. We must fix that at once!!

Lets not fall into the trap of penis envy here. Ruby does not need a whole bunch of features added to it just because some other language has them.

The original poster may not have a perfect grasp of English, and therefore
his expression of his ideas was imperfect. Nonetheless, his suggestions
were interesting and could lead to worthwhile idioms, if not features, in
Ruby. Your dismissiveness helps no one.

The posters command of English was not an issue and even he did not use it as an excuse but what he did not explain (and I believe that his command of English is up to the task) is why these features were lacking from Ruby. 'Other languages have them' is not good enough.



.



Relevant Pages

  • Re: Where did the prophet really live?
    ... features were in the spoken language or not. ... Now the point that Macdonald makes is that Sabaic was the prestige ... medieval arab historians had reported inscriptions ...
    (soc.religion.islam)
  • Re: Amazing LINQ for .Net
    ... >>> dynamic typing, use a different language. ... why even use types at all, if Ruby apparantly is so great? ... functional programming concepts into OOP. ... C#'s new features that help facilitate a more functional approach as ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Is C99 the final C? (some suggestions)
    ... I can't think of a single feature in C99 that would come as ... There are a number of features in C99 that I will steer away from if ... > * a library function that allows the retrieval of the size of a memory ... With the restrictions of the C language, I think you are going to find ...
    (comp.lang.c)
  • Re: What are your favorite Ruby features?
    ... I'm creating a new language which borrows heavily from Ruby, ... what features of Ruby its users enjoy the most. ... Finally, this may come as a shock to those who read my posts, but I tend to think that TDD support systems, beginning with the lowly assert() method, should behave like a debugger's variable watch system when they fail. ...
    (comp.lang.ruby)
  • Re: Equality, Assignment and The Emperors New Clothes
    ... Unfortunately, the features were designed ... the basic features of the language so that they can work together, ... suppose the language designers create a new feature to solve that same ... In R5RS, three pages or used ...
    (comp.lang.scheme)