OSV Word Order
Restrict Language uses Object-Subject-Verb (OSV) word order for calls. The value being transformed comes first, then the function that receives it. This keeps data flow visible and avoids function-first call syntax.
Supported Call Forms
value |> function
(left, right) combine
() make_default
Function-first calls are not part of the v0.0.1 surface.
Pipe Operator
The pipe operator passes the value on the left as the first argument to the function on the right.
fun double: (value: Int32) -> Int32 = {
value * 2
}
fun main: () -> Int32 = {
21 |> double
}
Pipelines read left to right:
fun score: (value: Int32) -> Int32 = {
value + 1
}
fun main: () -> Int32 = {
41
|> score
|> double
}
Multiple Arguments
Functions with multiple arguments use a tuple before the function name.
fun add: (left: Int32, right: Int32) -> Int32 = {
left + right
}
fun main: () -> Int32 = {
(10, 32) add
}
The same rule applies inside larger expressions:
fun clamp_min: (value: Int32, minimum: Int32) -> Int32 = {
value < minimum then {
minimum
} else {
value
}
}
fun main: () -> Int32 = {
val raw = 7
(raw, 10) clamp_min
}
Scoped Verb Clauses
A higher-order verb can open its final function argument as a typed scope. The ordinary object stays before the verb, while the complete clause becomes the object of the next verb.
fun main: () -> Int32 = {
val numbers: List<Int32> = [1, 2, 3, 4]
val doubled = numbers map {
it * 2
} filter {
it > 2
}
(doubled, 0) fold { |total, number|
total + number
}
}
An unheaded scope receives one contextual it binding. Use the existing
lambda binder syntax in the scope header when a name is clearer or the
callback has multiple parameters:
values map { |value|
value + 1
}
The compiler checks these scopes exactly like ordinary lambdas. Nested
implicit it scopes are rejected; name at least one binder so ownership and
capture intent remain visible.
Pattern Matching
match keeps the matched value first.
fun score_or_zero: (score: Option<Int32>) -> Int32 = {
score match {
Some(value) => { value }
None => { 0 }
}
}
Impl Functions
impl blocks define functions that are selected by the receiver type. They do
not introduce object-style method calls; the call still places the receiver in
the argument position.
record Score {
value: Int32
}
record Penalty {
value: Int32
}
impl Score {
fun amount: (self: Score) -> Int32 = {
self.value
}
}
impl Penalty {
fun amount: (self: Penalty) -> Int32 = {
0 - self.value
}
}
fun main: () -> Int32 = {
val score = Score { value: 11 }
(score) amount
}
When the same function name exists for multiple record types, the receiver type chooses the implementation.
Record Values
Record literals use : field initializers, and field access is separate from
function calls.
record Point {
x: Int32,
y: Int32
}
fun sum_point: (point: Point) -> Int32 = {
point.x + point.y
}
fun main: () -> Int32 = {
val point = Point { x: 10, y: 20 };
point |> sum_point
}
Best Practices
- Keep pipelines short enough to scan.
- Name functions by the transformation they perform.
- Put side-effecting functions at the end of a pipeline.
- Use
valfor intermediate names when it makes ownership transfer clearer.
Summary
OSV makes ownership and data flow explicit: values move from left to right,
multi-argument calls use tuples, and impl functions are still called through
OSV syntax.
For the complete callback model and the current map, filter, and fold
surface, continue to Higher-Order Functions and Collection Transforms.