Catching null pointers at compile time is just one of the benefits of building the language around a reasonably powerful type system. Other benefits of precise typing will come to Java with Generics (note that GJ and Nice are based on different powerful type systems).
Nice provides both extensible data (objects) and extensible operations (functions) in a unified way. Class based extensible data is similar to Java, but Nice multi-methods are very different from Java methods.
In Nice, choice of method implementation at execution time is based on the class of all the method parameters (not just the type of the receiver object). In Nice, and at the assembler level in Java, you can think of the receiver object as just another parameter passed to a static method. In other words myObj.myMethod( myParm ) is equivalent to myMethod( myObj, myParm ). In Java, which version of myMethod that gets used depends only on the type of the myObj object. In Nice it depends on the dynamic types all the parameters — including both myObj and myParam. In other words Nice seeks a closer fit for the method based not only on the reciever’s dynamic type but on the parameters as well. Like Java, there are also static constraints on the types of the parameters. Like Java, the compiler checks there exists at least one match.
Methods can be added to an existing class without editing the source (and without subclassing). (Yes, you can add a method to String.)
Nice provides for functional programming — parameters and return types can be methods or functions, anonymous functions, closures or Hindley Milner ML based type system extended for subtypes.
available on the web at:
optional Replicator mirror
Please email your feedback for publication, letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear wording, broken/redirected link reports, suggestions to improve this page or comments to Roedy Green : . If you want your message, your name or email kept confidential, not considered for public posting, please explicitly specify that. Unless you state otherwise, I will treat your message as a letter to the editor that I may or may not publish in the feedback section. After that, it will be too late to retract it. If you disagree with something I said, especially when sending an ad-hominem attack, a rant composed mainly of obscenities or a death threat, please quote the offending passage and cite the web page where you found it, tell me why you think it is wrong, and, if possible, provide some supporting evidence. I can’t very well fix erroneous or ambiguous text if I can’t find it.
Your face IP:[184.108.40.206]
|Feedback||You are visitor number 13,075.|