Bento
 
SourceForge.net Logo
> Bento Home > Bento Overview > Introduction to Bento
Introduction to Bento
 
 

introduction

Bento is an object-oriented declarative language for defining web sites. Being object-oriented means that in Bento you work with objects, code-and-data assemblages which follow object-oriented principles.

Objects are either external objects (defined in some other language and passed to Bento according to a language-specific mechanism) or Bento objects (defined in Bento). Every Bento object has an associated definition which determines how that object is constructed. The definition may contain static data (generally HTML, DHTML, PHP, JSP or other textual information), code (Bento constructions) or both.

In addition to constructions, a definition may also contain other definitions. These definitions may be for new kinds of objects, or they may be alternatives to definitions found somewhere above in the containment hierarchy, the tree of definitions consisting of the top level object (called core in Bento), the definitions it contains, the definitions they contain and so forth, or the class hierarchy (described below).

A definition is accessible anywhere in its scope, which consists of its parent (the containing definition) and the parent's descendants in both the containment and class hierarchies. Any of these descendants, however, may contain a definition by the same name, which would take precedence within its own scope.

The creation of multiple definitions with the same name but different scopes is called overriding, and is one of the major sources of power of OO. It allows content to vary with context.

Web pages, in Bento, are objects; when a Bento compiler generates an HTML file or a Bento server serves up a web page, it merely constructs the appropriate page object and returns the results.

Class Distinctions

But there's more to it. In OO terms, the definitions described above are class definitions, since any number of objects may be constructed from a definition. Moreover, in Bento, objects need not be defined from scratch. A definition can be declared to be a modification (or, in object-oriented terminology, a subclass) of another definition (its superclass). The subclass inherits the definition of the superclass, then adds to this definition and/or makes changes to (overrides, see above) parts of it.

A definition may be subclassed any number of times, and subclasses may themselves be subclassed. The result is a tree of definitions called a class hierarchy (not to be confused with the containment hierarchy described earlier).

Hello, World

Consider the following fragment of Bento code:



    page hello [|
        <h1>Hello, world</h1>
    |]

            
This fragment defines a web page called "hello". Here is the actual page that results.

The heart of this fragment looks a lot like HTML. And so it is. But the more interesting thing is what you don't see. Where are <head> and <body> and all the other tags that appear in the resulting page? The answer is that "hello" is a subclass of a page, and inherits the definition of "page" which includes the tags common to all pages.


top


Use of any software, source code and documentation obtained from this site is governed by the Bento Poetic License.

Copyright © 2003 by bentodev.org