LPC (programming Language) - Basic Structure

Basic Structure

Almost everything in LPC is an object. However, LPC does not precisely use the concept of a class (MudOS has something called a class, but it is really a struct). Instead, LPC objects are blueprint objects and clones of blueprint objects, in a prototype-based programming model. One can treat a blueprint object much as a class in other object-oriented languages.

Each object has variables (attributes) and functions (methods). The variables store the object's state; the functions are executable routines that can be called in the object. An object is uniquely defined by the name of the file in which it comes from, plus, if a clone, a numeric identifier. In a typical implementation, a clone of the file /lib/weapon.c which is the third clone created in the current run session will be /lib/weapon#3. The blueprint object corresponding to /lib/weapon.c is simply /lib/weapon. In a MUD game, common objects include rooms, weapons, armor, and non-player character (NPCs). Most mudlibs define inheritable objects for such common things. In the LPMud 2.4.5 mudlib, for example, the parent object for all rooms is /lib/room.

In LPC, it is not possible to syntactically declare class-only or instance-only methods and attributes; all functions and variables may be accessed identically in blueprints and in clones. For example, "/lib/user"->number_of_users would call the number_of_users function directly in the blueprint instance of /lib/user.c. (However, a controversial mechanism in many drivers called "shadowing" allows instance methods to be emulated to some extent by permitting one object to "overlay" its function set onto another, in effect interposing itself between external function calls and the shadowed object.) Direct external access to variables is also not supported; all interaction between objects is carried out through function calls (notwithstanding that data structures pointed to by variables are independent of objects and changes to them are visible in all objects referencing those data structures simultaneously, and that some drivers have privileged functions allowing a cumbersome form of external variable access that permits inspection but not mutation).

Read more about this topic:  LPC (programming Language)

Famous quotes containing the words basic and/or structure:

    The gay world that flourished in the half-century between 1890 and the beginning of the Second World War, a highly visible, remarkably complex, and continually changing gay male world, took shape in New York City.... It is not supposed to have existed.
    George Chauncey, U.S. educator, author. Gay New York: Gender, Urban Culture, and the Making of the Gay Male World, 1890-1940, p. 1, Basic Books (1994)

    One theme links together these new proposals for family policy—the idea that the family is exceedingly durable. Changes in structure and function and individual roles are not to be confused with the collapse of the family. Families remain more important in the lives of children than other institutions. Family ties are stronger and more vital than many of us imagine in the perennial atmosphere of crisis surrounding the subject.
    Joseph Featherstone (20th century)