Saturday, October 15, 2011

Improved import declarations, plans for future developent

With Revision 202, the functionality of import declarations has been extended.

  • Items in data and class namespaces can be selected by name. 
  • It is now possible to re-export imported items. 
  • Everything that can be imported can be aliased for use in the current package.
Taken together, this will make it possible to create packages that provide an interface to some library consisting of arbitrary many sub-packages, so that implementation details remain hidden and full functionality of many modules can be imported with a single import.
Unfortunately, changes in some module of a library that are not merely additions will continue to break binary backwards compatibility of the client modules that are compiled against an earlier version. This is due to limitations of the JVM, where all classes, methods and so on have only one name.
The new features are documented in chapter 5 of the language reference.

Next steps in development will be:

  • Apply the new import features to the Prelude (which will be just an interface to some most basic modules) and evolve a standard library that should cover most of Haskell's, where applicable and desirable.
  • Explore the possibilities of Java7 method handles. I see 3 areas where they could be useful: 1) better performance for higher order functions and partial function applications - some measurements suggest that programs may spend 25% or more of their time constructing and evaluating thunks  2) great reduction of the number of class files resulting from compilation of a Frege module - currently, every function is compiled to a class 3) as a technical means an interpreter could employ in interpreting user input that contains references to already compiled code such as library functions.
  • Compiler support for import of whole Java classes along with their methods and static values. This will not only save typing, but also promote a canonical way how to map Java APIs in Frege. 
  • Type system support for some basic subtyping relationships - for example, one should be able to pass a BufferedReader as argument to a native function that takes a Reader.

No comments:

Post a Comment

Comments will be censored by me as I see fit, most likely if they contain insults or propaganda for ideologies I do not like. Comments that are on topic will not be censored. If I leave a comment uncensored this does not imply that I agree with the opinions expressed therein.