Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which Scala features are internally implemented using reflection?

It is a well known fact that structural types are implemented through reflection. Are there maybe any other language constructs which use reflection?

like image 416
Nermin Serifovic Avatar asked Jan 02 '11 04:01

Nermin Serifovic


2 Answers

This is closely related to structural types, but any anonymous object instance, ie

new { def print = ("hello world") }.print

will use reflection.

http://scala-programming-language.1934581.n4.nabble.com/Structural-types-reflection-td3071599.html

like image 185
Adam Rabung Avatar answered Nov 15 '22 18:11

Adam Rabung


Enumerations use reflection to find out about all of the possible values for the enumeration for the nameOf function. (See the populateNameMap method in Enumeration.scala). This is done once, the first time you call nameOf for a particular Enumeration type.

like image 27
Ken Bloom Avatar answered Nov 15 '22 16:11

Ken Bloom