Re: Object or Package ?
Daniel Bonniot <[email protected]> Thu, 07 Jul 2005 22:40:21 +0200
| Newsgroups | gmane.comp.lang.nice.general |
|---|---|
| Message-ID | <[email protected]> |
David Bernard wrote:
> I need some precision to understand my misunderstood about organisation.
> When I start to read document about Nice, I was happy because I think
> great no more need to declare Helper class to enhance existing Class
> (e.g. StringUtils in jakarta-commons/lang). I put the "jar" in the
> classpath and the compiler detect extension So I could write :
>
> String s ="...";
> if (s.isBlank) {
> ...
> }
>
> without need to import other thing than String to tell compiler that
> String is an alias for java.lang.String.
>
> So if method about String could be define in any package. Do I need to
> tell from witch package, the method come ?
You need to import packages to declare that you are using them. Then all the
methods in those packages become available.
> In this case Nice is a functionnal language with advanced feature about
> structure (like Constructor, Properties, Inheritance,...). I thing it's
> important because it helps to understand the approach and how to
> organize source, documentation/api (object or functionnal),
Nice is a unification of the object and the functional style. This is made
possible by multi-methods.
So, like in OO, you can create subclasses of existing classes. And like in
functional style, you can create new operations (functions, methods) operating
on existing types (classes).
The fact that both are possible is what makes Nice more modular and flexible.
But indeed, it is at the heart of your concerns about how programs should be
organized. I think this duality means that we shouldn't enforce one style over
the other. Of course each project can decide to favor one, but the other
always remains possible when needed (and eventually it will).
> Is it equivalent to write "o.equals(o2)" and "equals(o, o2)" ?
Yes, indeed, the first one is just syntactic sugar for the second.
Daniel
-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar