At the heart of ProtoScript lies the Prototype system, where every entity is a Prototype—a node in a graph that encapsulates properties, behaviors, and relationships.
Multiple Inheritance
prototype Buffalo_City : City, Location {
Name =
"Buffalo"
;
}
Stored Data (Extensional Facts)
City.State = NewYork_State
Computed Relationships (Intensional Rules)
function
IsInState
(
State state
) :
bool
{
return
this
.State == state;
}
Prototypes form a directed graph where:
Simple city Modeling
prototype City {
System.String Name =
""
;
State State =
new
State();
}
prototype NewYork_City : City {
Name =
"New York City"
;
}
prototype State {
Collection Cities =
new
Collection();
}
// Create bidirectional relationship
NewYork_City.State = NewYork_State;
NewYork_State.Cities = [NewYork_City];
The Simpsons Character Model
prototype Person {
System.String Gender =
""
;
Location Location =
new
Location();
Collection ParentOf =
new
Collection();
}
prototype Homer : Person {
Gender =
"Male"
;
Location = SimpsonsHouse;
ParentOf = [Bart, Lisa, Maggie];
}
prototype SimpsonsHouse : Location {
System.String Address =
"742 Evergreen Terrace"
;
}
Basic Structure
prototype City {
System.String Name =
""
;
State State =
new
State();
}
Prototype Declaration
prototype Name : Parent1, Parent2 {
// Properties, functions, members
}
Properties (Stored Relationships)
Type Name = DefaultValue;
Functions (Computed Relationships)
function
Name
(
Parameters
) :
ReturnType
{
// Graph operations
}
Annotations
[Lexeme.SingularPlural(
"city"
,
"cities"
)]
prototype City { ... }
Categorization Operator
prototype -> Type { Condition }
Collections
Collection Cities =
new
Collection();
int i = 0
and
int j = -1
Output Shadow:
int _ = _
(initialized integer variable pattern)
[SubType]
prototype InitializedIntVariable_SubType : CSharp_VariableDeclaration {
function
IsCategorized
(
CSharp_VariableDeclaration
var
) :
bool
{
return
var
-> CSharp_VariableDeclaration {
this
.Type.TypeName ==
"int"
&&
this
.Initializer !=
new
CSharp_Expression()
};
}
}
[TransferFunction(NL)]
function
Whisper_To_VerbalCommunication
(
WhisperBase action
) :
VerbalCommunication
{
VerbalCommunication meaning =
new
VerbalCommunication();
meaning.SourceActor = action.Subject;
meaning.Volume =
"Quiet"
;
return
meaning;
}
prototype CSharp_VariableDeclaration {
CSharp_Type Type =
new
CSharp_Type();
System.String VariableName =
""
;
CSharp_Expression Initializer =
new
CSharp_Expression();
}
prototype SQL_Select {
Collection Columns =
new
Collection();
SQL_Table Table =
new
SQL_Table();
System.String Limit =
""
;
}
prototype Need {
BaseObject Subject =
new
BaseObject();
Action
Object
=
new
Action();
}
System.String, System.Int32
mirror C# primitives
prototype City {
System.String Name =
""
;
function
FormatName
(
) :
System
.
String
{
return
String
.Format(
"City: {0}"
, Name);
}
}
Graph Structure
Primitive values (strings, booleans, integers) as graph nodes:
System.String[
"Buffalo"
]
// String as graph node
System.Boolean[True]
// Boolean as graph node
System.Int32[
42
]
// Integer as graph node