Follow-up to this SO question.
Suppose I have the code
def bar(param: {def foo: Unit}*) = param.foreach(x => x.foo)
This function causes object param
to invoke a method named foo
[EDIT]
I was wondering if the following is possible (with or without reflection)
param
is fixed at compile time, the name of the function (in this case foo
) is supplied at runtimeparam
and the name of the function foo
are supplied at runtimeparam
is fixed at compile time, the name of the function, the function parameters, values and return types are supplied at runtime.I realize Structural typing already uses reflection. So my question is if Scala can take care of it or if I have explicitly use reflection in my code. I think the 3rd one requires reflection for which I can use the ASM library.
If I understand your question:
param
has indeed a method foo
with the correct signature.foo
of each param
So you don't need to use reflection yourself, but you should keep it mind that reflection will be used at runtime, and could potentially decrease performances.