First-class environments
Michael Vanier <[email protected]>
| Newsgroups | gmane.comp.lang.lightweight |
|---|---|
| Message-ID | <[email protected]> |
This list has been pretty moribund for a while, so I'd like to introduce a new topic. I've been getting interested in the notion of languages that support first-class environments i.e. environments as a data structure that can be grabbed and manipulated by a programmer. The impetus for this was reading about metaprogramming in Ruby, which in that language amounts to being able to extend object environments at runtime. This makes certain useful coding idioms possible e.g. reading from a database and creating objects that contain the database columns as fields. This is used to good effect in web frameworks like Ruby on Rails, purportedly drastically reducing the amount of boilerplate code relative to similar frameworks in e.g. Java. More generally, some authors have pointed out that many language constructs e.g. modules, classes, objects are to a large extent just variations on the environment concept, and functions are largely just code + environment. So the appeal of first-class environments conceptually is that they might allow you to have a more minimal core language in which you could define whatever module/class/object/function semantics you wanted. What I'd like to know are: 1) What are the best/most important/most famous papers on this subject? 2) What are peoples' opinions on this? I'd especially like to hear about elegant coding idioms using first-class environments and also horror stories (if any). For instance, are there certain important language features or optimizations that first-class environments make impossible? Mike