Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better usability for reflective invocations #8221

Closed
scabug opened this issue Feb 1, 2014 · 3 comments
Closed

Better usability for reflective invocations #8221

scabug opened this issue Feb 1, 2014 · 3 comments
Milestone

Comments

@scabug
Copy link

scabug commented Feb 1, 2014

In the current scheme of things, performing reflective invocations that are more or less simple in such languages/systems as Java and C# is quite convoluted.

When you want to reflectively call a method on a given object in Java, you figure out the object's class, then look up the corresponding java.lang.reflect.Method and finally simply call Method.invoke, passing the given object and the arguments.

In Scala this requires a significant amount of ceremony. First you have to obtain a runtime mirror, then you use it to reflect the object's class symbol, then you look up a method symbol in that class, then you need to obtain a method mirror using the calculated method symbol, and only then can you call apply on the resulting mirror.

@scabug
Copy link
Author

scabug commented Feb 1, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8221?orig=1
Reporter: @xeno-by
Affected Versions: 2.10.0, 2.11.0

@scabug
Copy link
Author

scabug commented Feb 1, 2014

@xeno-by said:
One of the ideas to improve usability is to merge traversals of the symbol table (reflecting a class, looking up a method) with reflection performed on mirrors. If we could say ru.reflect(instance).reflectMethod(name)(args), then things would become much better.

@SethTisue
Copy link
Member

chances of this ever getting addressed in Scala 2 seem slim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants