Lots of stuff to do

Computers, Programming Languages and Operating Systems

Friday, June 30, 2006

First Class Things

In computing, a first-class object (also -value, -entity, -citizen), in the context of a particular programming language, is an entity which can be used in programs without restriction (when compared to other kinds of objects in the same language). Depending on the language, this can imply:

  1. being expressible as an anonymous literal value
  2. being storable in variables
  3. being storable in data structures
  4. having an intrinsic identity (independent of any given name)
  5. being comparable for equality with other entities
  6. being passable as a parameter to a procedure/function
  7. being returnable as the result of a procedure/function
  8. being constructable at runtime
-wikipedia

First class objects are very useful because of the properties 2, 6+7, and 8. The benefit of first class stuff would be that you can store it for later use, even if what you are storing is very complicated.
  • For example, you can create a user-interface layout, and store that as a file. That means that different configurations of user interface are merely files which describe what the user interface is.
  • Another example of using first class things is when we turn information resource locators into first class objects. This allows us manipulation of our query independent from manipulation of the information that the query points to.
  • A third example would be file logs - that is, our information system would keep a log of all functions that have been invoked to reach a file. This type of object would be able to be used for file history purposes, such as bibliographies, sourcing data, finding sources of good/bad data, direct file modification via modifying the log, the ability to undo any operation applied to a file.
First class stuff is also related to the model-viewer-controller approach, because what we are enforcing is that every piece of information has a way to be viewed. This could be implemented as some sort of inheritance of a show function that all things must inherit from.

However, our objects are often more than data - they have functional purposes. For example, the user interface, resource locators and file logs have a functional purpose. As we have described, when we modify these files, we are modifying the very functionality of the computer. Changing a resource locator would allow us to see different information, changing the interface information would change how our interface is laid out on the computer. This can be solved by basing the system on a set of many reflectors - that is, all programs are dividied into a component of core logic which is separated from presentation, description, and other information.

Such a separation is good because, as mentioned, it allows us to do higher order operations on our information, but more than that, it allows us to reuse the same functions and techniques that we have used for plain information on higher order data, since they are also first class stuff.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home