Noun Particles
1. Introduction
Noun particles in Sagal serve as the fundamental building blocks for representing or referring to entities within the framework. These entities can include data, objects, concepts, operations, and more—similar to how nouns function in natural languages.
Noun particles are essential for establishing context, subject matter, and meaning within a clause, making them key elements in constructing semantically meaningful expressions in Sagal.
2. Structure
Below is the general structure for how noun particles are defined:
id: <clause_id> # Unique identifier for the clause
particle: noun # Specifies that this is a noun particle
body:
- <identifier> # The identifier or name of the noun
- <descriptor_clause> # Describes or qualifies the noun
- <binding_clause> # Represents the value or reference associated with the noun2.1. Signature
2.1.1. Identifier
The <identifier> is the name or label for the noun.
It provides the specific or general reference for the noun particle and could represent concepts like book, car, person, Ali.
The <identifier>, along with the <clause_id>, serves as the primary means of referencing this particular entity within the program.
It function much like the subject in a sentence or a variable name in a programming language.
2.1.2. Descriptor Clause
The <descriptor_clause> defines and qualifies the noun, acting as both a type system and a means to add meaningful context.
At its simplest, it handles basic types like strings, integers, and collections, but its true strength lies in its ability to represent complex structures.
Beyond basic data types, it allows for more nuanced descriptions, similar to how adjectives or noun phrases add meaning in natural languages.
It can specify relationships, attributes, or characteristics, offering a rich method to define nouns in a more contextualized way.
This becomes especially useful when dealing with indefinite nouns or when the <binding_clause> is missing, as it helps clarify the noun’s context or characteristics.
For example:
- "A list of completed tasks," where the descriptor defines "completed tasks"
- "The car that John owns," where the descriptor defines "owned by John"
In essence, the descriptor clause is not just a type indicator, but a tool to enrich the noun with specific traits or relationships, making it a versatile feature within Sagal’s structure. For simplicity, we will focus on basic types for now, with further elaboration to follow in the subsequent sections.
2.1.3. Binding Clause
The <binding_clause> in Sagal represents the actual value or reference tied to a noun.
It serves as the means by which a noun is "bound" to a specific instance, object, or clause.
This is particularly significant when the noun is definite or when referring to specific entities within the program.
At its simplest, the binding clause can contain direct values such as numbers or strings. However, it can also refer to more complex clauses or objects, similar to variables or references in traditional programming languages. When the binding is missing—such as when dealing with indefinite nouns or when the value has yet to be assigned—the descriptor clause becomes critical, providing context and meaning for the noun.
3. Types
3.1. Definiteness
In Sagal, definiteness plays a crucial role in distinguishing between specific and general references, much like definite and indefinite articles in natural languages (e.g. "the" vs "a" in English). The definiteness of a noun is determined by the presence or absence of a binding clause.
3.1.1. Definite Nouns
Definite nouns refer to specific entities that are clearly identifiable within the context.
In Sagal, a noun is considered definite when the <binding_clause> is provided, explicitly associating the noun with a particular value or reference.
3.1.2. Indefinite Nouns
Indefinite nouns, on the other hand, refer to general or non-specific entities. These are nouns that lack a binding clause, leaving them open to interpretation or assignment later. Indefinite nouns are often used to introduce new concepts or objects, just as indefinite articles are used in natural languages ("a" or "an" in English).
Here are some examples:
# Example of a definite noun:
id: 0x03
head: noun
body:
- book # The identifier for the noun
- object # Descriptor indicating it's a physical object
- 0xA001 # Binding clause; the noun refers to a specific book
# Example of a indefinite noun:
id: 0x04
particle: noun
body:
- car # The identifier for the noun
- object # Descriptor indicating it's a physical object
# No binding clause, making this an indefinite noun3.2. Reference
In Sagal, references are used to link one clause or noun to another, creating connections between different entities within a program. These references allow for modularity and reusability, similar to how variables or pointers work in traditional programming languages. References in Sagal are crucial for managing relationships between clauses, whether they are simple values or more complex structures.
3.2.1 Direct References
A direct reference is when a noun is explicitly tied to another clause or entity using the binding clause.
This binding clause contains a reference to another clause by its unique identifier (id).
3.2.2 Indirect References
It’s also possible to reference clauses indirectly by using another clause or mulitple clauses as intermediaries.
Here are some examples:
# A book entity that is referenced later
id: 0xA001
head: noun
body:
- book
- object
- "The Sagal Specification"
# Referencing the previously defined book
id: 0x05
head: noun
body:
- "favorite_book"
- object
- 0xA001 # Binding clause referencing the book entity
# An indirect reference to the previously defined book
id: 0x06
head: noun
body:
- open_book
- object
- 0x05 # References the favorite_book, allowing indirect access to the book3.3. Possession
Possession allows a noun to represent ownership or association between two entities, similar to possessive constructs in natural languages like English ("John's car").
In Sagal, one way to represent possession is to utilize the <descriptor_clause>, which defines the association of the noun to another entity.
There are other ways to represent possession, which we will cover in later sections.
In the meantime, let’s take an example where we define a "book owned by John." It can be represented as follows:
# Assuming the type "book owned by John" has clause id 0xA003
id: 0x07
head: noun
body:
- current_book # Identifier or label for this particular book
- 0xA003 # Reference to "book owned by John" type clause
- 0xA004 # Optional value or reference3.4. Collectivity and Composition
In Sagal, nouns can represent not just individual entities but also collective or composite groups, much like collective nouns in natural languages (e.g., "team," "group," "set"). This allows Sagal to handle entities that are composed of multiple items, whether they are homogeneous (e.g., a list of numbers) or heterogeneous (e.g., a group of people and objects).
3.4.1 Collectivity
Collective nouns in Sagal represent a single entity made up of multiple similar items.
The <descriptor_clause> can be used to specify that the noun refers to a collection or list of items.
id: 0x09
head: noun
body:
- team # Collective noun that groups individuals
- list_of_people # Descriptor clause defining the collective nature
- [0xA02, 0xA03, 0xA04] # References to individual people3.4.2 Composition
For more complex structures, composition allows a noun to represent different types of elements grouped together, much like a composite object in programming.
id: 0x10
head: noun
body:
- vehicle_parts # A group of different parts of vehicle
- list # Descriptor indicating composition
- [0xB01, 0xB02] # References to different types of parts4. Derived Noun Types
Derived noun types in Sagal expand on the core noun particle structure, enabling more nuanced representations of meaning. These derived types include concepts such as demonstrative nouns, relative nouns, collective nouns, compound nouns, and quantifiers. By leveraging the combination of descriptor clauses and binding clauses, developers can construct and manage more advanced noun forms seamlessly. This flexibility extends the noun representation to handle both natural language-inspired structures and more specialized noun types found in programming languages, such as typed/dynamic variables, pointers, constants, enumerations, and etc.
5. Evaluation
When a noun particle is evaluated, Sagal examines its key components, the <descriptor_clause> and <binding_clause>, to determine the noun’s identity, type, and whether it is associated with a specific value or reference.
- Descriptor Evaluation: If present, the
<descriptor_clause>adds further meaning to the noun. This can include resolving the noun’s type, attributes, or relationships (e.g., "the car owned by John"). - Binding Evaluation: If the noun is bound to a specific value or reference, the evaluation process resolves this binding to provide the final, concrete meaning of the noun within the program.
For definite nouns, this means resolving a reference to a specific instance.
For indefinite nouns, the
<descriptor_clause>may provide temporary context until the noun is later bound.
5.1. Scope
Noun clauses in Sagal are evaluated within the scope of the clauses in which they are defined. The evaluation process ensures that references to other clauses or external values are properly resolved. This includes evaluating references to previously defined clauses or dynamically changing references as the program progresses.
5.2. Context
Context plays a significant role in Sagal’s evaluation process.
While the <descriptor_clause> is the primary element that defines the noun context, the overall meaning of a noun is also influenced by the surrounding clauses.
This contextual information shapes the interpretation of the noun, helping determine how it fits into the broader logic of the program.
Note We will delve deeper into concrete examples of the noun evaluation process once we cover additional particles and structures in later sections.