Jon Pretty | 24 Dec 14:01

Re: Scala Object Notation ( SCON? )

John Nilsson wrote:
> This doesn't fit with the requirement of instantiating a Person (type
> Person isn't quite the same is it?) without creating a new subclass per
> instance dose it?

Probably not; I don't think the compiler does this optimisation.

And I sometimes forget constraints I don't agree with. ;-)

>> So many options, but none of them quite as concise as JSON...
> 
> If you skip the type declaration I'd say it's close enough.

Probably; I was only suggesting it for the people who like conciseness,
thou I'm actually happy to type a few more characters for the benefit of
clearer code.

Another problem with the code I suggested is that it doesn't allow
methods to be inherited from a Person class, so I would have to conclude
that there's nothing better, or clearer in the context of Scala, than to
write:

   val person = new Person {
     def name = "Peter"
     def age = 20
   }

Merry Christmas,
Jon

--

-- 
Jon Pretty | Sygneca Ltd.


Gmane