Skip to content

Fragments

Andrew Johnson edited this page Oct 2, 2024 · 30 revisions

Fragments are the main data structure in the compiler used to represent code objects as they are rendered. A Fragment is modelled as a map from Strings to S-Expressions. Fragments are available transparently to the type-system, compiler, AND the programmer. Fragments may be used to model a wide variety of code objects, so the data structure is fundamentally dynamic. Dynamic pattern matching is then used by the rest of the compiler to manipulate these Fragments. Functions that manipulate Fragments are also exposed to the programmer within the rendering context. This interplay between dynamic and static objects creates the fundamental compilation unit throughout the entire compilation process.

What is a Blob?

A blob function is a function that will become a fragment directly when called. Blob can be annotated to any function as a calling convention. The Blob calling convention can be described as an idiomatic "inline" calling convention.

f := λ: Blob(: x X). (
   (:program x)
   (:frame x)
   (:unframe x)
);

Here the x and y arguments are destructured as individual fragments to create another fragment which will become the result of applying the f function.

Clone this wiki locally