top | item 2179226 Scala's upcoming dynamic capabilities 28 points| DanielRibeiro | 15 years ago |squirrelsewer.blogspot.com | reply 9 comments order hn newest [+] [-] rit|15 years ago|reply Last week I spent a little bit of time trying to figure out how the Dynamic trait works and what its good for.I managed to do a quick and dirty 5 minute mockup of a "Callable" Map that lets you invoke keys as method names:https://gist.github.com/797513 [+] [-] gtani|15 years ago|reply examples with XML treehttps://gist.github.com/783394what to call it?http://groups.google.com/group/scala-language/browse_thread/... [+] [-] metageek|15 years ago|reply def invokeDynamic(name: String)(args: Any*) = { println("Invoke Dynamic: (name = %s)(args: %s)".format(name, args)) get(name.asInstanceOf[String]) } Why do you need the asInstanceOf(), when name is already declared to be a String?Sorry if this is obvious; I don't know Scala (I've glanced at it, but the 2.8 compiler is too slow on my laptop--as in, about one line per minute). load replies (1) [+] [-] pietrofmaggi|15 years ago|reply A recent interview of Martin Odersky on SE-Radio introduces this and other nice features that are in the works for Scala: http://www.se-radio.net/2011/02/episode-171-scala-update-wit... [+] [-] carsongross|15 years ago|reply "You're going the wrong way!"http://www.youtube.com/watch?v=NEZv0FUPtcc [+] [-] xtho|15 years ago|reply I guess scala isn't already complex or rather implicit enough.Is this implemented as a library or does it also require changes to the language/compiler? [+] [-] baconserker|15 years ago|reply It required a small language change, which I believe you can see in it's entirety here: https://lampsvn.epfl.ch/trac/scala/changeset/23993
[+] [-] rit|15 years ago|reply Last week I spent a little bit of time trying to figure out how the Dynamic trait works and what its good for.I managed to do a quick and dirty 5 minute mockup of a "Callable" Map that lets you invoke keys as method names:https://gist.github.com/797513 [+] [-] gtani|15 years ago|reply examples with XML treehttps://gist.github.com/783394what to call it?http://groups.google.com/group/scala-language/browse_thread/... [+] [-] metageek|15 years ago|reply def invokeDynamic(name: String)(args: Any*) = { println("Invoke Dynamic: (name = %s)(args: %s)".format(name, args)) get(name.asInstanceOf[String]) } Why do you need the asInstanceOf(), when name is already declared to be a String?Sorry if this is obvious; I don't know Scala (I've glanced at it, but the 2.8 compiler is too slow on my laptop--as in, about one line per minute). load replies (1)
[+] [-] gtani|15 years ago|reply examples with XML treehttps://gist.github.com/783394what to call it?http://groups.google.com/group/scala-language/browse_thread/...
[+] [-] metageek|15 years ago|reply def invokeDynamic(name: String)(args: Any*) = { println("Invoke Dynamic: (name = %s)(args: %s)".format(name, args)) get(name.asInstanceOf[String]) } Why do you need the asInstanceOf(), when name is already declared to be a String?Sorry if this is obvious; I don't know Scala (I've glanced at it, but the 2.8 compiler is too slow on my laptop--as in, about one line per minute). load replies (1)
[+] [-] pietrofmaggi|15 years ago|reply A recent interview of Martin Odersky on SE-Radio introduces this and other nice features that are in the works for Scala: http://www.se-radio.net/2011/02/episode-171-scala-update-wit...
[+] [-] carsongross|15 years ago|reply "You're going the wrong way!"http://www.youtube.com/watch?v=NEZv0FUPtcc
[+] [-] xtho|15 years ago|reply I guess scala isn't already complex or rather implicit enough.Is this implemented as a library or does it also require changes to the language/compiler? [+] [-] baconserker|15 years ago|reply It required a small language change, which I believe you can see in it's entirety here: https://lampsvn.epfl.ch/trac/scala/changeset/23993
[+] [-] baconserker|15 years ago|reply It required a small language change, which I believe you can see in it's entirety here: https://lampsvn.epfl.ch/trac/scala/changeset/23993
[+] [-] rit|15 years ago|reply
I managed to do a quick and dirty 5 minute mockup of a "Callable" Map that lets you invoke keys as method names:
https://gist.github.com/797513
[+] [-] gtani|15 years ago|reply
https://gist.github.com/783394
what to call it?
http://groups.google.com/group/scala-language/browse_thread/...
[+] [-] metageek|15 years ago|reply
Sorry if this is obvious; I don't know Scala (I've glanced at it, but the 2.8 compiler is too slow on my laptop--as in, about one line per minute).
[+] [-] pietrofmaggi|15 years ago|reply
[+] [-] carsongross|15 years ago|reply
http://www.youtube.com/watch?v=NEZv0FUPtcc
[+] [-] xtho|15 years ago|reply
Is this implemented as a library or does it also require changes to the language/compiler?
[+] [-] baconserker|15 years ago|reply