vars introspection

View: New views
9 Messages — Rating Filter:   Alert me  

vars introspection

by Andrew Gaydenko :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

Hi!

Say, I want to find all public vars of some object with inknown type. I can
use something like getDeclaredMethods(), use java modifiers, find getters and
setters (last one with "_$eq" suffix). I'm not sure this way is legal, as it
depends on the language implementation. Is there more legal way?


Andrew

Re: vars introspection

by Jamie Webb-2 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

On 2008-01-05 19:25:01 Andrew Gaydenko wrote:
> Hi!
>
> Say, I want to find all public vars of some object with inknown type.
> I can use something like getDeclaredMethods(), use java modifiers,
> find getters and setters (last one with "_$eq" suffix). I'm not sure
> this way is legal, as it depends on the language implementation. Is
> there more legal way?

Unfortunately not. Maybe Scala will grow its own reflection library at
some point (or better, property syntax), but at present I think you're
doing the best you can.

/J

Re: vars introspection

by Andrew Gaydenko :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

======= On Saturday 05 January 2008, Jamie Webb wrote: =======

> On 2008-01-05 19:25:01 Andrew Gaydenko wrote:
> > Hi!
> >
> > Say, I want to find all public vars of some object with inknown type.
> > I can use something like getDeclaredMethods(), use java modifiers,
> > find getters and setters (last one with "_$eq" suffix). I'm not sure
> > this way is legal, as it depends on the language implementation. Is
> > there more legal way?
>
> Unfortunately not. Maybe Scala will grow its own reflection library at
> some point (or better, property syntax), but at present I think you're
> doing the best you can.
>
> /J

Jamie,

It's pleasantly to know about "doing the best" :-) Thanks!

So, the most interesting (for me) question here is: is "_$eq" subject of
change? Of course, nobody can predict. Nevertheless, if we say about current
moment, are there any real reasons/plans this implementation detail may be
changed? Saying in another words, if I write some method AnyRef =>
Map[String,Class] to get info about all public vars, is there probability the
language will change such way it will not be possible just rewrite the single
method?

As for possible future property syntax - is it intended to "be compatible"
with 'var' declaration?


Andrew

Re: vars introspection

by Martin Odersky :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

Hi Andrew,

There are no plans to change _=, and there are no concrete plans to
add properties either.

Hope this helps

 -- Martin



On Jan 5, 2008 6:23 PM, Andrew Gaydenko <a@...> wrote:

> ======= On Saturday 05 January 2008, Jamie Webb wrote: =======
>
> > On 2008-01-05 19:25:01 Andrew Gaydenko wrote:
> > > Hi!
> > >
> > > Say, I want to find all public vars of some object with inknown type.
> > > I can use something like getDeclaredMethods(), use java modifiers,
> > > find getters and setters (last one with "_$eq" suffix). I'm not sure
> > > this way is legal, as it depends on the language implementation. Is
> > > there more legal way?
> >
> > Unfortunately not. Maybe Scala will grow its own reflection library at
> > some point (or better, property syntax), but at present I think you're
> > doing the best you can.
> >
> > /J
>
> Jamie,
>
> It's pleasantly to know about "doing the best" :-) Thanks!
>
> So, the most interesting (for me) question here is: is "_$eq" subject of
> change? Of course, nobody can predict. Nevertheless, if we say about current
> moment, are there any real reasons/plans this implementation detail may be
> changed? Saying in another words, if I write some method AnyRef =>
> Map[String,Class] to get info about all public vars, is there probability the
> language will change such way it will not be possible just rewrite the single
> method?
>
> As for possible future property syntax - is it intended to "be compatible"
> with 'var' declaration?
>
>
> Andrew
>

Re: vars introspection

by Andrew Gaydenko :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

Martin, hi!

Thanks! The answer from you is valuable especially :-)


Andrew

======= 2008-01-08, "martin odersky" <martin.odersky@...> wrote:

Hi Andrew,

There are no plans to change _=, and there are no concrete plans to
add properties either.

Hope this helps

 -- Martin



On Jan 5, 2008 6:23 PM, Andrew Gaydenko <a@...> wrote:

> ======= On Saturday 05 January 2008, Jamie Webb wrote: =======
>
> > On 2008-01-05 19:25:01 Andrew Gaydenko wrote:
> > > Hi!
> > >
> > > Say, I want to find all public vars of some object with inknown type.
> > > I can use something like getDeclaredMethods(), use java modifiers,
> > > find getters and setters (last one with "_$eq" suffix). I'm not sure
> > > this way is legal, as it depends on the language implementation. Is
> > > there more legal way?
> >
> > Unfortunately not. Maybe Scala will grow its own reflection library at
> > some point (or better, property syntax), but at present I think you're
> > doing the best you can.
> >
> > /J
>
> Jamie,
>
> It's pleasantly to know about "doing the best" :-) Thanks!
>
> So, the most interesting (for me) question here is: is "_$eq" subject of
> change? Of course, nobody can predict. Nevertheless, if we say about current
> moment, are there any real reasons/plans this implementation detail may be
> changed? Saying in another words, if I write some method AnyRef =>
> Map[String,Class] to get info about all public vars, is there probability
the
> language will change such way it will not be possible just rewrite the
single
> method?
>
> As for possible future property syntax - is it intended to "be compatible"
> with 'var' declaration?
>
>
> Andrew
>




Re: vars introspection

by Alex Boisvert-3 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

On 1/8/08, martin odersky <martin.odersky@...> wrote:
There are no plans to change _=, and there are no concrete plans to
add properties either.

Hi Martin,

Just curious, is this because you think

1) properties aren't an interesting problem to solve
2) there are no known good solution that satisfy your requirements
3) there's hope for a more generic (meta?) solution to materialize later
4) there are good argument against this language feature
5) the problem can be solved above the language ( i.e., libraries/framework)
6) none of the above
7) all of the above  :-]

or for some other good reasons?  I'm just trying to read your mind on the subject since it's a feature request that comes up fairly often and one I'm interested in as well.

alex

Re: vars introspection

by Viktor Klang :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message



On Jan 8, 2008 10:00 PM, Alex Boisvert <boisvert@...> wrote:
On 1/8/08, martin odersky <martin.odersky@...> wrote:
There are no plans to change _=, and there are no concrete plans to
add properties either.

Hi Martin,

Just curious, is this because you think

1) properties aren't an interesting problem to solve
2) there are no known good solution that satisfy your requirements
3) there's hope for a more generic (meta?) solution to materialize later
4) there are good argument against this language feature
5) the problem can be solved above the language ( i.e., libraries/framework)
6) none of the above
7) all of the above  :-]

or for some other good reasons?  I'm just trying to read your mind on the subject since it's a feature request that comes up fairly often and one I'm interested in as well.

+1

 

alex



--
_____________________________________
/                                                                 \
       /lift/ committer ( www.liftweb.net)
     SGS member (Scala Group Sweden)
 SEJUG member (Swedish Java User Group)
\_____________________________________/

Re: vars introspection

by Erik Engbrecht :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

I'll bet a round of beer that there is a more generic solution...most likely several of them.
 
But that doesn't make it the reason, because as far as I can tell there are no concrete plans for any sort of metaprogramming facility, either.
 
So I'm interested to know the reasons as well.

 
On 1/8/08, Alex Boisvert <boisvert@...> wrote:
On 1/8/08, martin odersky <martin.odersky@...> wrote:
There are no plans to change _=, and there are no concrete plans to
add properties either.

 
Hi Martin,

Just curious, is this because you think

1) properties aren't an interesting problem to solve
2) there are no known good solution that satisfy your requirements
3) there's hope for a more generic (meta?) solution to materialize later
4) there are good argument against this language feature
5) the problem can be solved above the language ( i.e., libraries/framework)
6) none of the above
7) all of the above  :-]

or for some other good reasons?  I'm just trying to read your mind on the subject since it's a feature request that comes up fairly often and one I'm interested in as well.

alex



--
http://erikengbrecht.blogspot.com/

Re: vars introspection

by Martin Odersky :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

On Jan 8, 2008 10:00 PM, Alex Boisvert <boisvert@...> wrote:

> On 1/8/08, martin odersky <martin.odersky@...> wrote:
> > There are no plans to change _=, and there are no concrete plans to
> > add properties either.
>
> Hi Martin,
>
> Just curious, is this because you think
>
> 1) properties aren't an interesting problem to solve
> 2) there are no known good solution that satisfy your requirements
> 3) there's hope for a more generic (meta?) solution to materialize later
> 4) there are good argument against this language feature
> 5) the problem can be solved above the language ( i.e., libraries/framework)
> 6) none of the above
> 7) all of the above  :-]
>
Hi Alex,

I think it's a combination of 3) and, more importantly, the desire to
stabilize Scala. I think for the moment we want to go slow adding new
features, so that IDE's and other tools get a chance ot catch up.

So I suggest we continue to think about it, but with a much longer
timeframe in mind, and keeping all possibilities open, including the
one of keeping the status quo.

Cheers

 -- Martin