Yes, Scala is definitely smarter. I used the term leak loosely mostly
because I'm coming from the Java perspective and as you point out in Java
the method isn't accessible so there's no performance gotcha.
I'm happy Scala does what it does... and I'm glad Jorge pointed out this
little intricacy between val's and objects.
alex
On Tue, Dec 2, 2008 at 12:19 PM, Marius <[EMAIL PROTECTED]> wrote:
>
> I don't think it is a "leak" because in this case a structural type
> has the same type with its parent, new entities (as Jorge explained)
> are not visible from outside of that type boundaries and Scala
> compiler still does a fair job to allow invocation of non-overridden
> members.
>
> For instance in Java there is no way to invoke them such as:
> class A {
> }
>
> A a = new A() {
> public void m() {
>
> }
> };
>
> a.m();
>
> will fail to compile
>
> Again .. Scala seems smarter :)
>
> Br's,
> Marius
>
>
> On Dec 2, 9:42 pm, "Alex Boisvert" <[EMAIL PROTECTED]> wrote:
> > Ok, I see now.
> >
> > I don't think I've ever written something like that... I normally just
> > implement a trait in anonymous classes -- I don't usually extend it.
> It's
> > interesting to see that structural types "leak" so easily.
> >
> > thanks!
> > alex
> >
> > On Tue, Dec 2, 2008 at 10:51 AM, Jorge Ortiz <[EMAIL PROTECTED]>
> wrote:
> > > class Foo
> >
> > > // type is singleton type Bar.type
> > > object Bar extends Foo {
> > > def exc = (new Exception).printStackTrace
> > > }
> >
> > > // type is structural type Foo{def exc: Unit}
> > > val Baz = new Foo {
> > > def exc = (new Exception).printStackTrace
> > > }
> >
> > > // compare:
> > > Bar.exc
> > > Baz.exc
> >
> > > Singleton types get their own .class file. Structural types use
> reflection.
> >
> > > --j
> >
> > > On Tue, Dec 2, 2008 at 12:33 PM, Alex Boisvert <[EMAIL PROTECTED]
> >wrote:
> >
> > >> On Tue, Dec 2, 2008 at 10:24 AM, Jorge Ortiz <[EMAIL PROTECTED]
> >wrote:
> >
> > >>> If you add (non-overriden) fields to a val, they'll always be invoked
> via
> > >>> reflection, which takes a performance hit. Objects, on the other
> hand,
> > >>> define their own class so reflection isn't necessary.
> >
> > >> Can you give an example? I can't picture this from your description.
> >
> > >> alex
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---