Re:Scala: The Static Language that Feels Dynamic (Bruce Eckel)
by jorgeortiz85 on Sunday June 12, 2011 @08:38PM
(#2647751)
This is hard because Scala's XML support affects the parser. At the lexical level. Scala does have compiler plugins, but it doesn't have parser plugins.
[ Parent
| on HN ]
Re:Scala: The Static Language that Feels Dynamic (Bruce Eckel)
by corruptmemory on Sunday June 12, 2011 @09:09PM
(#2647792)
Agreed.
Macros and reader macros ;-)
Re:Scala: The Static Language that Feels Dynamic (Bruce Eckel)
by jorgeortiz85 on Sunday June 12, 2011 @09:44PM
(#2647837)
Let me know when you figure out how to statically type check those. You could publish a paper or two, I'm sure.
Re:Scala: The Static Language that Feels Dynamic (Bruce Eckel)
by corruptmemory on Sunday June 12, 2011 @10:12PM
(#2647886)
Nemerle already does it: http://nemerle.org/macros.html, so does Template Haskell: http://www.haskell.org/haskellwiki/Template_Haskell
Re:Scala: The Static Language that Feels Dynamic (Bruce Eckel)
by corruptmemory on Monday June 13, 2011 @10:51PM
(#2651621)
To reiterate a point implied by other commenters: macro-expansion is a compile-time operation. If the language utilizes a typing system to help promote sound programming then the results of the expansion will be compiled in the context of type constraints - the expansion is either sound or unsound w.r.t. such constraints.
To some extent there is a continuing popular schism with the idea that "strongly typed" must be synonymous with the lack of "eval", which, at least in principle, cannot be true. In fact, StandardML does have the ability to extend the environment of a program at run-time (as well as Typed Racket). All the necessary typing and meta-data is retained at run-time so that newly evaluated code is checked for type-consistency just like when the "main code" was compiled. So, not only can one expand macros at compile time and verify that the expansions are sound, one can also do the same at run-time.
Re:Scala: The Static Language that Feels Dynamic (Bruce Eckel)
by a_strange_guy on Monday June 13, 2011 @02:04AM
(#2648280)
You don't typecheck macros since they run at compile time. You typecheck the expanded code instead.
Re:Scala: The Static Language that Feels Dynamic (Bruce Eckel)
by samth on Monday June 13, 2011 @10:08AM
(#2649046)
And we did! Check out: http://blog.racket-lang.org/2011/03/languages-as-libraries-p...