Functions, Fields, and Shared Fields
An object may have functions and fields, just like any normal Fonc object. But fields defined in Trylid always have getter and setter functions defined; that is, they are "public".
There is also such a thing as a "shared field", whose value is shared by the prototype and all its clones, much like a "class variable" in class-oriented object-oriented systems.
proto MyProto
field my-field
my-shared-field = 'foo' # A shared field.
create: value
# Each clone has a separate value for "my-field".
my-field = value
bar
return my-shared-field + " " + value string
Prototypes Act as Classes and as Namespaces
In a prototype-based system like Fonc, objects act as both instances and as classes. In Trylid, they also can act as namespaces (a.k.a. packages). One prototype may be "contained" in another (as a shared field); functions in the child prototype have access to functions in the parent prototype.
proto WindowSystem
proto Event
create: raw-event
#...
proto Window
next-event
# Notice that it knows the name "Event":
return Event new: get-raw-event
There is a top-level namespace called "Trylid", which acts as a global namespace for all Trylid objects. There is a namespace called "Standard" which contains some common classes. [Currently, in "Standard", there is a prototype called "Object", from which all Trylid prototypes descend. In the future, the main Fonc "Object" prototype may be used instead, but it still will likely appear in "Standard", not "Trylid".] You can access the members of "Standard" without having to specify it explicitly. A namespace called "Pepsi" (actually "Standard Pepsi") allows access to Pepsi's namespace. And a namespace called "Posix" contains some prototypes that access types from the Posix C API.