[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-13 Thread Oleg G.
to Naftoli: i added implicits as you said and removed all 'onRegister' stuff, i think its useless.. Here's the result: http://github.com/ojow/Random-code/blob/master/RecordRelatedStuff.scala --~--~-~--~~~---~--~~ You received this message because you are

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-13 Thread Oleg G.
edit: not all 'onRegister' stuff but most of it, only left two points of extension for intercepting the prototype creation. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-13 Thread Oleg G.
On 13 окт, 10:40, David Pollak feeder.of.the.be...@gmail.com wrote: I've got a change on review board that will pick up vals and lazy vals that are MappedFields.  Seehttp://reviewboard.liftweb.net/r/40/ However, until certain defects in the Scala compiler

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-13 Thread David Pollak
On Mon, Oct 12, 2009 at 10:15 PM, Oleg G. ojo...@gmail.com wrote: After reading Naftoli's post i checked the way inner object laziness is implemented. And it appears to be not thread safe. It is not threadsafe. This is a known defect and is supposed to be addressed in 2.8. But, the cost of

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-12 Thread Oleg G.
I've spent some time and came up with this code: http://github.com/ojow/Random-code/blob/master/Test.scala I think it should allow all the needed stuff, it keeps meaning with the bytes and also: * its reusable/extensible in many directions, no static stuff * i checked generated .class files and

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-12 Thread Oleg G.
Well i don't think its a lot of complexity. Yes its 4 declarations instead of 1 for each field. But 3 of those are generatable by IDE same way as any Java IDE generates setters and getters. All the rest is spring-style instantiations/injections. And usage is even simplier and readable (i mean

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-12 Thread Oleg G.
On 13 окт, 00:08, naf g naftoli...@gmail.com wrote: Why do you have two classes, Model and Record? What are they and why are they interdependent? I thought about Model being a place for metainformation (like database structure, options/properties etc), or maybe it can be described as global

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-12 Thread Naftoli Gugenheim
So Model represents the database connection? 2009/10/12 Oleg G. ojo...@gmail.com On 13 окт, 00:08, naf g naftoli...@gmail.com wrote: Why do you have two classes, Model and Record? What are they and why are they interdependent? I thought about Model being a place for metainformation (like

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-12 Thread David Pollak
On Mon, Oct 12, 2009 at 10:38 AM, Oleg G. ojo...@gmail.com wrote: Well i don't think its a lot of complexity. You asked for feedback, I gave you my opinion. Yes its 4 declarations instead of 1 for each field. But 3 of those are generatable by IDE same way as any Java IDE generates

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-12 Thread Oleg G.
Thanks again for your answers, David. I've got your point and it all looks much more clear to me now. On 13 окт, 01:19, David Pollak feeder.of.the.be...@gmail.com wrote: On Mon, Oct 12, 2009 at 10:38 AM, Oleg G. ojo...@gmail.com wrote: Well i don't think its a lot of complexity. You asked

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-12 Thread David Pollak
I've got a change on review board that will pick up vals and lazy vals that are MappedFields. See http://reviewboard.liftweb.net/r/40/ However, until certain defects in the Scala compiler ( https://lampsvn.epfl.ch/trac/scala/ticket/2463 and https://lampsvn.epfl.ch/trac/scala/ticket/1006) are

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-12 Thread Oleg G.
After reading Naftoli's post i checked the way inner object laziness is implemented. And it appears to be not thread safe. Following code: class A { val a = 1 } class B { object b extends A } Generates getter for b as follows: public final B$b$ b(); Code: 0: aload_0 1: getfield

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-06 Thread Dirk Louwers
Well, I am only a beginner myself but here are my 2 cents: - My guess is that they are declared as inner objects to make it possible to reach certain global field properties through the companion MetaMapper object. - As far as I know traits cannot be directly instantiated, only extended or mixed

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-06 Thread Kris Nuttycombe
One major reason for the inner object pattern is that when you have a singleton object extending a trait, it is possible for the trait to reflect upon that object's class to obtain information like the name of the field. You'll see this pattern used throughout Lift (AnyVar subclasses RequestVar

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-06 Thread David Pollak
On Tue, Oct 6, 2009 at 7:52 AM, Kris Nuttycombe kris.nuttyco...@gmail.comwrote: One major reason for the inner object pattern is that when you have a singleton object extending a trait, it is possible for the trait to reflect upon that object's class to obtain information like the name of

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-06 Thread Tim Nelson
On Tue, Oct 6, 2009 at 10:10 AM, David Pollak feeder.of.the.be...@gmail.com wrote: I don't care for the pattern, but it comes from Scala history... so In the days of Scala 2.3, an inner object had different class and method visibility than a val instantiated in the same way. So, if you

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-06 Thread David Pollak
On Tue, Oct 6, 2009 at 8:20 AM, Tim Nelson tnell...@gmail.com wrote: On Tue, Oct 6, 2009 at 10:10 AM, David Pollak feeder.of.the.be...@gmail.com wrote: I don't care for the pattern, but it comes from Scala history... so In the days of Scala 2.3, an inner object had different class

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-06 Thread Oleg G.
Thanks for all the answers and especially for David's clarification. It would be really cool to upgrade the 'keeping the meaning with the bytes' thing (http://blog.lostlake.org/index.php?/archives/19-Keeping- the-meaning-with-the-bytes.html) to allow extension/customization. Generally, yes.  I

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-06 Thread David Pollak
On Tue, Oct 6, 2009 at 9:50 AM, Oleg G. ojo...@gmail.com wrote: Thanks for all the answers and especially for David's clarification. It would be really cool to upgrade the 'keeping the meaning with the bytes' thing (http://blog.lostlake.org/index.php?/archives/19-Keeping-

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-06 Thread Oleg G.
As i said before i'm not sure that i'm getting the whole picture and maybe my initial question is incorrect in its root. Still: Suppose i have a Person class declared with Mapper/Record and i want to reuse the class and all the code associated with it in another module/project. My first thought

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-06 Thread Naftoli Gugenheim
I want to raise another related point. Currently all mapped fields have to be passed this. Is there a way to not require it? Can Mapper or Record use an implicit object etc. to fill in this? Or could there be an inner derived class that knows its parent, like I recently did for ModelView? In

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-06 Thread Stefan Scott
I hope I don't wander too far off-topic here as I wend my way to the question at the end of this post (would it be useful to look at something like the OWL/SWRL web ontology and rule languages for liftweb?). I tend to generalize/abstract a lot - so if anyone with a theoretical bent is willing to

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-06 Thread David Pollak
On Tue, Oct 6, 2009 at 10:16 AM, Oleg G. ojo...@gmail.com wrote: As i said before i'm not sure that i'm getting the whole picture and maybe my initial question is incorrect in its root. Still: Suppose i have a Person class declared with Mapper/Record and i want to reuse the class and all

[Lift] Re: Why fields are declared as 'object' with Mapper/Record?

2009-10-06 Thread Naftoli Gugenheim
What you can do if I'm not mistaken, although not as good, is define in a base trait, def myField: MappedXXX ... and give different concrete object implementations. This way you have a common type that guarantees the field. On Tue, Oct 6, 2009 at 4:54 PM, David Pollak