object system
description of the object system
canvases, patches & subpatches:
canvases are the basis, where objects can be put on. they appear in two forms. as patches, saveable modules or as subpatches, which are located on another canvas they behave as object.
objects, abstractions, externals, libraries & namespaces:
objects are located on a canvas. they contain a number of inlets and outlets, which can be connected. the inlets or outlets can be either for messages or for audio signals. only xlets of the same type can be connected. objects are either part of the language, written in the pnpd language itself or dynamically loaded libraries written in c++. objects, that are written in the pnpd language itself are patches that can be written and edited independently. they are called abstractrions. dynamically loaded objects can either be externals or libraries. externals contain only one object, that has the same name as the external file. in contrary, libraries are allowed to contain more than one object.
to avoid nameclashes, the pnpd language contains namespaces, using . as namespace delimiter. namespaces are evaluated in the global scope (i.e. relative to the search pathes, of the interpreter) and in the local scope of a patch (i.e. the path of the patch file), taking folders and library names into account. if an object can't be uniquely identified, an error message is issued
the object foo.bar.myobject can be found in several ways:
- patch
foo/bar/myobject, foo/bar is the directory path, myobject is the patch file- external
foo/bar/myobject, foo/bar is the directory path, myobject is the external file- library
foo/bar/myobject, foo is the directory path, bar the library file, that contains an object myobject
arguments & attributes:
objects have two kinds of argument types: arguments and attributes.
- arguments
- arguments are defined by an atomlist. arguments can't be changed at runtime.
- attributes
- attributes a dictionary using a symbol as key and an atomlist as value. attributes are not limited in size and should only be used for a fine-grained customization of objects. if they are changed at runtime, they are saved with the patch
object orientation & scoping:
in the pnpd language, canvases are the equivalent to classes in object-oriented languages. they provide notions of constructors and destructors as well as data encapsulation.
constructors & destructors:
certain objects can be used as constructors and destructors in order to initialize or finalize the state of a canvas. the initialization objects are loadbang (sending a bang to the outlet) and init (sending an arbitrary message to an outlet), the finalizing counterparts are endbang and finalize. before the initialization and after the finalizing, no interaction with the interpreter is allowed. if data is being sent to a canvas before the time of the initialization (via inlets or message busses), these messages are queued and executed directly after the initialization.
scoping:
canvases can contain local objects. these ojects have to be declared explicitely and are only valid on this canvas and in the child canvases. however, they are not visible in other parts of the interpreter. if multiple local objects of the same type are available upwards in the hierarchy, the lowest is the only visible object.
