First class class objects, class vs. value namespaces, etc.

I was reading up on Scala and noticed that classes and value bindings have different namespaces. This got me thinking about how different languages treat classes. As an extreme case, consider Smalltalk vs. C++.

I Googled for papers like crazy, but turned up nothing. There's just too much cruft involving keywords like "first class classes" and like queries.

Are there any good comparative studies/overviews of the treatment of classes in different object oriented languages and the implications/trade offs/etc. of these different treatments?

Any manifestos promoting one or another treatment would be great as well.

Thanks much!

Scott

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

One syntactic issue

Many statically-typed languages make use of the ability to distinguish between types and values at parse time. This can apply to languages like C++ that are obviously not context-free, and also to some ML-like languages which use the (a,b) syntax both to represent tuple values and tuple types.

Smalltalk, Dylan and (AFAIK) Python treat classes as just plain old first-class objects. To continue the tuple example, in these languages a "tuple type" and a "tuple of two types" would have to be distinguished by some other mechanism.

The "Foo.class" (Java) and "typeof(Foo)" (C#) syntaxes make the act of reflecting from the type level to the value level explicit. This allows whatever beneficial properties come from having distinguished syntactic categories while also allowing users to treat types as values with low overhead.

This feels similar (but unrelated) to the issue of having to distinguish constructor tags from value symbols (often by alphabetic case) in languages with pattern matching.

Citeseer

You might try Citeseer, or another CS-specific search engine. It's typically much more helpful than Google.

One book on the subject

is Iain Craig's Object Oriented Programming Languages--Interpretation, which provides a great deal of discussion of the various flavors of OO languages.

See also Queinnec's LiSP

I also suggest to have a look at Christian Queinnec's Lisp in Small Pieces

There are some interesting stuff on this.

Also, object and classes have very different meanings in languages like OCaml, Java, CommonLisp (CLOS), Self, Cecil

Aardappel

I would also recommend looking at Aardappel's language design overview page. He has done a lot of work around various approaches to environments and related scoping constructs.

Lisp-2 vs Lisp-1

Consideration of a similar issue - whether values and functions should be in the same namespace - can be found on dreamsongs, or elsewhere by googling 'lisp-1 lisp-2'.