Перейти к содержанию
(Lispex)2.0Спецификация · до выпуска

Поиск по документации

Поиск по английскому тексту спецификации

Введите вопрос, символ, код диагностики или команду.

Содержание

Поиск по спецификации
Лиспекс 2.0 · Язык · Глава I.7

Глава I.7

Conditions

Handle domain failures with lexical guards. Preserve structured conditions and terminal resource failures.

Непереведённый текст показан на английском языке

Scope

A rule can recover from a domain failure with a lexical guard. A terminal failure ends the request.

This chapter defines conditions and guards. Resources defines resource events. CLI and diagnostics defines diagnostic presentation.

Condition codes and data

A condition contains a stable phase, code, and typed data. A guard reads those fields through the condition accessors. Presentation follows CLI and diagnostics.

A raised occurrence carries its own canonical program site. The canonical-outcome rule reports that site. Source maps connect it to source text. A Condition value carries neither source coordinates nor a program site.

7.1 Expose stable condition data

A condition exposes a stable phase, code, and canonical typed data. Its raised occurrence supplies the canonical failure site. Presentation choices preserve those fields.

7.1ред. 2
lispex.rule.v2.conditions.canonical-condition

Why

Rules need to branch on the same failure across products and locales. Source paths and message wording would make that decision depend on presentation.

Keep a condition through presentation changes

lispex.example.v2.conditions.condition-presentation · ред. 2

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (car input)))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare this source",
    "evaluate": "finite values sufficient for the stated finite calculation"
  },
  "requests": [
    {
      "input": {
        "kind": "empty-list"
      }
    },
    {
      "input": {
        "kind": "empty-list"
      }
    }
  ],
  "executionContexts": [
    {
      "messageLocale": "en",
      "sourceLabel": "first.scm"
    },
    {
      "messageLocale": "ko",
      "sourceLabel": "renamed.scm"
    }
  ],
  "comparison": "Keep the canonical program and semantic request fixed while changing diagnostic presentation.",
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Условиеdomain.type
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.type",
    "data": {
      "operation": "car",
      "argument": "0",
      "path": [],
      "expected": "pair",
      "actual": "empty-list"
    }
  }
}
Условиеdomain.type
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.type",
    "data": {
      "operation": "car",
      "argument": "0",
      "path": [],
      "expected": "pair",
      "actual": "empty-list"
    }
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "comparison": {
    "conditionCodeEqual": true,
    "canonicalConditionDataEqual": true,
    "canonicalFailureSiteEqual": true,
    "guestPresentationFields": false
  }
}
Вызов продукта

Ожидаемый результат

Both evaluations report the same car domain condition and canonical failure site. Neither returns a datum. Product invocation awaits its 2.0 adapter.

The request uses documentation notation. The diagnostic catalog fixes condition codes. Product execution awaits its 2.0 adapter.

7.2 Construct and inspect typed conditions

A Condition is an immutable internal value. Every code in this catalog has phase evaluate. The diagnostic catalog uses the same codes and field meanings.

A field record is a proper association list of dotted pairs. Each pair has a string key as its car and a field value as its cdr. Keys are unique. The constructor sorts them by unsigned UTF-8 bytes. This representation uses ordinary Datum values.

FormMeaning
(make-condition code fields)Validate the closed schema and return a Condition. Construction does not raise that Condition.
(condition? value)Return #t for a Condition and #f for every other value.
(condition-phase condition)Return the string evaluate.
(condition-code condition)Return the exact code string.
(condition-data condition)Return the canonical immutable field record.
(raise condition)Raise that Condition at the current canonical program site.

The constructor uses the exact fields below. Each field is required. No additional field is accepted. Construction validates the data. It does not perform the operation named by a field.

CodeSemantic fieldsMeaning
runtime.not-callableactual uses TypeTagThe evaluated operator is not a procedure.
runtime.arityminimum uses Nat, maximum uses NatOrFalse, actual uses NatThe call has an unsupported argument count. A false maximum means no upper arity bound.
runtime.value-countexpected uses Nat, actual uses NatA context receives the wrong number of internal values.
domain.typeoperation uses Operation, argument uses Nat, path uses DataPath, expected uses TypeRequirement, actual uses TypeTagAn argument component fails the required type. The path starts at that argument.
domain.rangeoperation uses Operation, argument uses Nat, reason uses RangeReasonAn argument has an accepted type but violates a value constraint.
domain.indexoperation uses Operation, argument uses Nat, index uses Integer, length uses NatThe index is below zero or at least the sequence length.
domain.equalityoperation uses EqualityOperation, operand uses Operand, path uses DataPath, actual uses TypeTagAn operand contains a value outside the comparison domain. The path identifies its first invalid component.
domain.division-by-zerooperation uses Operation, argument uses NatThe operation requires division by exact zero. Its library catalog row identifies the argument.
domain.numericoperation uses Operation, argument uses Nat, reason uses NumericReasonAn exact numeric operation fails the stated numeric requirement.
domain.conditionreason uses ConditionReason, field uses StringOrFalseCondition construction rejects a code or field record. A false field names the whole input.
domain.applicationtag uses String, data uses DatumThe program supplies its own tag and portable data.

For unequal list lengths, identify the first list argument whose length differs from the first list. Check list arguments in argument order. Invalid slice ordering identifies the ending bound argument. Invalid UTF-8 identifies the bytevector argument. The owning library Rule determines when each value constraint fails.

Argument and entry positions start at zero. Counts and indices are exact integers. They never depend on host word size.

TypeSemantic domain
NatAn exact nonnegative integer
IntegerAny exact integer
NatOrFalseNat or #f
StringA raw Unicode string
StringOrFalseString or #f
OperationA string. An automatically raised condition uses the exact public procedure binding name. A constructed condition preserves its supplied string.
EqualityOperationThe string eq?, eqv?, or equal?
OperandThe exact integer 0 or 1
DatumPortable data from the Datum definition
DataPathA proper list of the segments below. An empty list selects the whole argument or operand.
Path segmentSelected component
(car)Pair car
(cdr)Pair cdr
(index n)Vector element at the exact nonnegative index n
(key s)Host record field with the exact string key s

Path tags are symbols. A key segment describes a host record mapping. It does not introduce a guest record value kind.

EnumExact string members
TypeTagboolean, integer, rational, character, symbol, empty-list, pair, string, vector, bytevector, procedure, condition
TypeRequirementEvery TypeTag, number, proper-list, scalar, datum, nonnegative-integer, positive-integer, rounding-mode
RangeReasonnegative-count, invalid-scalar, invalid-byte, invalid-radix, invalid-scale, unequal-lengths, invalid-slice-order, invalid-utf8
NumericReasonnonintegral-exponent, nonpositive-base, invalid-rounding-mode, rounding-required
ConditionReasonunknown-code, terminal-code, payload-shape, key-type, duplicate-field, missing-field, extra-field, field-type

After ordinary call evaluation and arity checks, construction follows the order below. The first failed check ends construction.

OrderCheckFailure
1The code is a stringdomain.type for argument 0 with expected type string
2The code belongs to this catalogdomain.condition with unknown-code or terminal-code and false field
3The outer field list is properdomain.condition with payload-shape and false field
4Visit each entry in list order. Check its pair shape, string key, and key uniqueness before advancing.A nonpair uses payload-shape. A nonstring key uses key-type. Both use false field. A repeated key uses duplicate-field and that key.
5Every required key is present. Scan required keys in canonical order.domain.condition with missing-field and the first missing key
6Every supplied key belongs to the schema. Scan supplied keys in canonical order.domain.condition with extra-field and the first unknown key
7Every value has its declared type. Scan keys in canonical order.domain.condition with field-type and the first invalid field key

Enum values must match exactly. Paths have the exact segment shapes above. Portable data validation follows the Datum traversal order. Field values cannot contain a procedure or another Condition.

Each typed accessor and raise accepts one Condition. A different argument raises domain.type with expected type condition. condition? accepts any one internal value.

A Condition contains no source path, message, stack, or failure site. It is not a Datum. Data copied from its accessors remains ordinary portable data. Equality applied to a Condition follows the existing comparison domain rules.

A raised occurrence carries the Condition and its canonical program site. An unmatched guard propagates that same occurrence. Explicit raise creates an occurrence at its own site even when it uses a captured Condition.

Preparation, resource, admission, qualification, evidence, operational, and internal diagnostics have no guest Condition constructor. Boundary decoding and result validation also run outside an active guest guard. Their known codes cause terminal-code when passed to make-condition.

Construction, inspection, and raising use the ordinary resource accounts. Payload limits use the named resource model limits. A failed reservation ends evaluation without truncating fields or running guest recovery.

7.2ред. 4
lispex.rule.v2.conditions.condition-catalog

Why

A closed code catalog gives every product the same recoverable failures. Typed fields make recovery independent of message text and host details. Ordinary association lists keep condition data inside the existing portable value model. A separate raised occurrence preserves useful failure locations without exposing source identity to guest code.

Report call and value count failures

lispex.example.v2.conditions.condition-runtime-families · ред. 1

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (if (= input 0)
          (0 1)
          (if (= input 1)
              ((lambda (a b) a) 1)
              (+ (values 1 2) 3)))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare each source",
    "evaluate": "finite values sufficient for each stated calculation and complete condition encoding"
  },
  "requests": [
    {
      "input": {
        "kind": "integer",
        "value": "0"
      }
    },
    {
      "input": {
        "kind": "integer",
        "value": "1"
      }
    },
    {
      "input": {
        "kind": "integer",
        "value": "2"
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Условиеruntime.not-callable
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "runtime.not-callable",
    "data": {
      "actual": "integer"
    }
  }
}
Условиеruntime.arity
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "runtime.arity",
    "data": {
      "minimum": "2",
      "maximum": "2",
      "actual": "1"
    }
  }
}
Условиеruntime.value-count
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "runtime.value-count",
    "data": {
      "expected": "1",
      "actual": "2"
    }
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "conditions": {
    "phase": "evaluate",
    "codes": [
      "runtime.not-callable",
      "runtime.arity",
      "runtime.value-count"
    ],
    "presentationFields": false
  }
}
Вызов продукта

Ожидаемый результат

The requests identify a nonprocedure operator, a wrong argument count, and a wrong internal value count. Product execution awaits its 2.0 adapter.

The request uses documentation notation. Diagnostic fields use their typed representation. This example fixes no result or receipt bytes. Product execution remains not-run.

Construct domain fields and unbounded arity

lispex.example.v2.conditions.condition-domain-payloads · ред. 1

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (let ((condition (make-condition (car input) (cdr input))))
        (list (condition-phase condition)
              (condition-code condition)
              (condition-data condition)))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare each source",
    "evaluate": "finite values sufficient for each stated calculation and complete condition encoding"
  },
  "requests": [
    {
      "input": {
        "kind": "pair",
        "car": {
          "kind": "string",
          "value": "domain.type"
        },
        "cdr": {
          "kind": "list",
          "items": [
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "path"
              },
              "cdr": {
                "kind": "empty-list"
              }
            },
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "operation"
              },
              "cdr": {
                "kind": "string",
                "value": "car"
              }
            },
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "expected"
              },
              "cdr": {
                "kind": "string",
                "value": "pair"
              }
            },
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "argument"
              },
              "cdr": {
                "kind": "integer",
                "value": "0"
              }
            },
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "actual"
              },
              "cdr": {
                "kind": "string",
                "value": "empty-list"
              }
            }
          ]
        }
      }
    },
    {
      "input": {
        "kind": "pair",
        "car": {
          "kind": "string",
          "value": "domain.range"
        },
        "cdr": {
          "kind": "list",
          "items": [
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "reason"
              },
              "cdr": {
                "kind": "string",
                "value": "negative-count"
              }
            },
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "operation"
              },
              "cdr": {
                "kind": "string",
                "value": "make-vector"
              }
            },
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "argument"
              },
              "cdr": {
                "kind": "integer",
                "value": "0"
              }
            }
          ]
        }
      }
    },
    {
      "input": {
        "kind": "pair",
        "car": {
          "kind": "string",
          "value": "domain.index"
        },
        "cdr": {
          "kind": "list",
          "items": [
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "operation"
              },
              "cdr": {
                "kind": "string",
                "value": "vector-ref"
              }
            },
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "length"
              },
              "cdr": {
                "kind": "integer",
                "value": "3"
              }
            },
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "index"
              },
              "cdr": {
                "kind": "integer",
                "value": "-1"
              }
            },
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "argument"
              },
              "cdr": {
                "kind": "integer",
                "value": "1"
              }
            }
          ]
        }
      }
    },
    {
      "input": {
        "kind": "pair",
        "car": {
          "kind": "string",
          "value": "runtime.arity"
        },
        "cdr": {
          "kind": "list",
          "items": [
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "minimum"
              },
              "cdr": {
                "kind": "integer",
                "value": "1"
              }
            },
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "maximum"
              },
              "cdr": {
                "kind": "boolean",
                "value": false
              }
            },
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "actual"
              },
              "cdr": {
                "kind": "integer",
                "value": "0"
              }
            }
          ]
        }
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Результат("evaluate" "domain.type" (("actual" . "empty-list") ("argument" . 0) ("expected" . "pair") ("operation" . "car") ("path" . ())))
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "list",
    "items": [
      {
        "kind": "string",
        "value": "evaluate"
      },
      {
        "kind": "string",
        "value": "domain.type"
      },
      {
        "kind": "list",
        "items": [
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "actual"
            },
            "cdr": {
              "kind": "string",
              "value": "empty-list"
            }
          },
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "argument"
            },
            "cdr": {
              "kind": "integer",
              "value": "0"
            }
          },
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "expected"
            },
            "cdr": {
              "kind": "string",
              "value": "pair"
            }
          },
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "operation"
            },
            "cdr": {
              "kind": "string",
              "value": "car"
            }
          },
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "path"
            },
            "cdr": {
              "kind": "empty-list"
            }
          }
        ]
      }
    ]
  }
}
Результат("evaluate" "domain.range" (("argument" . 0) ("operation" . "make-vector") ("reason" . "negative-count")))
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "list",
    "items": [
      {
        "kind": "string",
        "value": "evaluate"
      },
      {
        "kind": "string",
        "value": "domain.range"
      },
      {
        "kind": "list",
        "items": [
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "argument"
            },
            "cdr": {
              "kind": "integer",
              "value": "0"
            }
          },
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "operation"
            },
            "cdr": {
              "kind": "string",
              "value": "make-vector"
            }
          },
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "reason"
            },
            "cdr": {
              "kind": "string",
              "value": "negative-count"
            }
          }
        ]
      }
    ]
  }
}
Результат("evaluate" "domain.index" (("argument" . 1) ("index" . -1) ("length" . 3) ("operation" . "vector-ref")))
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "list",
    "items": [
      {
        "kind": "string",
        "value": "evaluate"
      },
      {
        "kind": "string",
        "value": "domain.index"
      },
      {
        "kind": "list",
        "items": [
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "argument"
            },
            "cdr": {
              "kind": "integer",
              "value": "1"
            }
          },
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "index"
            },
            "cdr": {
              "kind": "integer",
              "value": "-1"
            }
          },
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "length"
            },
            "cdr": {
              "kind": "integer",
              "value": "3"
            }
          },
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "operation"
            },
            "cdr": {
              "kind": "string",
              "value": "vector-ref"
            }
          }
        ]
      }
    ]
  }
}
Результат("evaluate" "runtime.arity" (("actual" . 0) ("maximum" . #f) ("minimum" . 1)))
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "list",
    "items": [
      {
        "kind": "string",
        "value": "evaluate"
      },
      {
        "kind": "string",
        "value": "runtime.arity"
      },
      {
        "kind": "list",
        "items": [
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "actual"
            },
            "cdr": {
              "kind": "integer",
              "value": "0"
            }
          },
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "maximum"
            },
            "cdr": {
              "kind": "boolean",
              "value": false
            }
          },
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "minimum"
            },
            "cdr": {
              "kind": "integer",
              "value": "1"
            }
          }
        ]
      }
    ]
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "construction": {
    "canonicalKeyOrder": true,
    "operationExecuted": false,
    "falseMaximumMeansUnboundedArity": true,
    "negativeIndexRemainsExact": true
  }
}
Вызов продукта

Ожидаемый результат

The constructor preserves each typed field and returns keys in canonical order. A false maximum denotes an arity without an upper bound. Product execution awaits its 2.0 adapter.

The request uses documentation notation. Diagnostic fields use their typed representation. This example fixes no result or receipt bytes. Product execution remains not-run.

Locate invalid equality operands

lispex.example.v2.conditions.condition-equality-paths · ред. 1

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (if (= input 0)
          (eq? (vector 1) #f)
          (if (= input 1)
              (eqv? #f "text")
              (equal? (list 1 (lambda () 0)) '(1 2))))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare each source",
    "evaluate": "finite values sufficient for each stated calculation and complete condition encoding"
  },
  "requests": [
    {
      "input": {
        "kind": "integer",
        "value": "0"
      }
    },
    {
      "input": {
        "kind": "integer",
        "value": "1"
      }
    },
    {
      "input": {
        "kind": "integer",
        "value": "2"
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Условиеdomain.equality
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.equality",
    "data": {
      "operation": "eq?",
      "operand": "0",
      "path": [],
      "actual": "vector"
    }
  }
}
Условиеdomain.equality
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.equality",
    "data": {
      "operation": "eqv?",
      "operand": "1",
      "path": [],
      "actual": "string"
    }
  }
}
Условиеdomain.equality
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.equality",
    "data": {
      "operation": "equal?",
      "operand": "0",
      "path": [
        {
          "kind": "cdr"
        },
        {
          "kind": "car"
        }
      ],
      "actual": "procedure"
    }
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "comparison": {
    "firstInvalidComponents": [
      "left-root",
      "right-root",
      "left-second-list-element"
    ],
    "completeLeftValidationFirst": true,
    "conditionCarriesSourceCoordinates": false
  }
}
Вызов продукта

Ожидаемый результат

Scalar comparison rejects aggregate operands. Structural comparison identifies the nested procedure in the left list. Product execution awaits its 2.0 adapter.

The request uses documentation notation. Diagnostic fields use their typed representation. This example fixes no result or receipt bytes. Product execution remains not-run.

Keep exact numeric failure fields

lispex.example.v2.conditions.condition-numeric-families · ред. 1

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (let ((condition (make-condition (car input) (cdr input))))
        (list (condition-phase condition)
              (condition-code condition)
              (condition-data condition)))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare each source",
    "evaluate": "finite values sufficient for each stated calculation and complete condition encoding"
  },
  "requests": [
    {
      "input": {
        "kind": "pair",
        "car": {
          "kind": "string",
          "value": "domain.division-by-zero"
        },
        "cdr": {
          "kind": "list",
          "items": [
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "operation"
              },
              "cdr": {
                "kind": "string",
                "value": "/"
              }
            },
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "argument"
              },
              "cdr": {
                "kind": "integer",
                "value": "1"
              }
            }
          ]
        }
      }
    },
    {
      "input": {
        "kind": "pair",
        "car": {
          "kind": "string",
          "value": "domain.numeric"
        },
        "cdr": {
          "kind": "list",
          "items": [
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "reason"
              },
              "cdr": {
                "kind": "string",
                "value": "nonintegral-exponent"
              }
            },
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "operation"
              },
              "cdr": {
                "kind": "string",
                "value": "expt"
              }
            },
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "argument"
              },
              "cdr": {
                "kind": "integer",
                "value": "1"
              }
            }
          ]
        }
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Результат("evaluate" "domain.division-by-zero" (("argument" . 1) ("operation" . "/")))
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "list",
    "items": [
      {
        "kind": "string",
        "value": "evaluate"
      },
      {
        "kind": "string",
        "value": "domain.division-by-zero"
      },
      {
        "kind": "list",
        "items": [
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "argument"
            },
            "cdr": {
              "kind": "integer",
              "value": "1"
            }
          },
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "operation"
            },
            "cdr": {
              "kind": "string",
              "value": "/"
            }
          }
        ]
      }
    ]
  }
}
Результат("evaluate" "domain.numeric" (("argument" . 1) ("operation" . "expt") ("reason" . "nonintegral-exponent")))
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "list",
    "items": [
      {
        "kind": "string",
        "value": "evaluate"
      },
      {
        "kind": "string",
        "value": "domain.numeric"
      },
      {
        "kind": "list",
        "items": [
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "argument"
            },
            "cdr": {
              "kind": "integer",
              "value": "1"
            }
          },
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "operation"
            },
            "cdr": {
              "kind": "string",
              "value": "expt"
            }
          },
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "reason"
            },
            "cdr": {
              "kind": "string",
              "value": "nonintegral-exponent"
            }
          }
        ]
      }
    ]
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "construction": {
    "numericCodes": [
      "domain.division-by-zero",
      "domain.numeric"
    ],
    "hostWidthUsed": false,
    "namedOperationsExecuted": false
  }
}
Вызов продукта

Ожидаемый результат

Numeric condition construction preserves the exact operation, argument position, and reason. It performs no numeric operation. Product execution awaits its 2.0 adapter.

The request uses documentation notation. Diagnostic fields use their typed representation. This example fixes no result or receipt bytes. Product execution remains not-run.

Inspect an application condition

lispex.example.v2.conditions.condition-accessors · ред. 1

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (let ((condition (make-condition "domain.application" input)))
        (list (condition? condition)
              (condition? input)
              (condition-phase condition)
              (condition-code condition)
              (condition-data condition)))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare each source",
    "evaluate": "finite values sufficient for each stated calculation and complete condition encoding"
  },
  "requests": [
    {
      "input": {
        "kind": "list",
        "items": [
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "tag"
            },
            "cdr": {
              "kind": "string",
              "value": "invalid-input"
            }
          },
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "data"
            },
            "cdr": {
              "kind": "list",
              "items": [
                {
                  "kind": "integer",
                  "value": "7"
                },
                {
                  "kind": "string",
                  "value": "field"
                }
              ]
            }
          }
        ]
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Результат(#t #f "evaluate" "domain.application" (("data" . (7 "field")) ("tag" . "invalid-input")))
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "list",
    "items": [
      {
        "kind": "boolean",
        "value": true
      },
      {
        "kind": "boolean",
        "value": false
      },
      {
        "kind": "string",
        "value": "evaluate"
      },
      {
        "kind": "string",
        "value": "domain.application"
      },
      {
        "kind": "list",
        "items": [
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "data"
            },
            "cdr": {
              "kind": "list",
              "items": [
                {
                  "kind": "integer",
                  "value": "7"
                },
                {
                  "kind": "string",
                  "value": "field"
                }
              ]
            }
          },
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "tag"
            },
            "cdr": {
              "kind": "string",
              "value": "invalid-input"
            }
          }
        ]
      }
    ]
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "conditionValue": {
    "immutable": true,
    "portable": false,
    "hasSite": false,
    "hasPresentationFields": false
  },
  "accessors": {
    "dataIsPortableDatum": true,
    "inputDataPromotedImplicitly": false
  }
}
Вызов продукта

Ожидаемый результат

The accessors return a fixed phase, a code string, and canonical portable fields. The original association list remains ordinary data. Product execution awaits its 2.0 adapter.

The request uses documentation notation. Diagnostic fields use their typed representation. This example fixes no result or receipt bytes. Product execution remains not-run.

Reject malformed condition construction

lispex.example.v2.conditions.condition-constructor-rejections · ред. 1

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (make-condition (car input) (cdr input))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare each source",
    "evaluate": "finite values sufficient for each stated calculation and complete condition encoding"
  },
  "requests": [
    {
      "input": {
        "kind": "pair",
        "car": {
          "kind": "string",
          "value": "domain.unknown"
        },
        "cdr": {
          "kind": "empty-list"
        }
      }
    },
    {
      "input": {
        "kind": "pair",
        "car": {
          "kind": "string",
          "value": "value.boundary"
        },
        "cdr": {
          "kind": "empty-list"
        }
      }
    },
    {
      "input": {
        "kind": "pair",
        "car": {
          "kind": "string",
          "value": "runtime.not-callable"
        },
        "cdr": {
          "kind": "integer",
          "value": "7"
        }
      }
    },
    {
      "input": {
        "kind": "pair",
        "car": {
          "kind": "string",
          "value": "runtime.not-callable"
        },
        "cdr": {
          "kind": "list",
          "items": [
            {
              "kind": "integer",
              "value": "7"
            }
          ]
        }
      }
    },
    {
      "input": {
        "kind": "pair",
        "car": {
          "kind": "string",
          "value": "runtime.not-callable"
        },
        "cdr": {
          "kind": "list",
          "items": [
            {
              "kind": "pair",
              "car": {
                "kind": "symbol",
                "value": "actual"
              },
              "cdr": {
                "kind": "string",
                "value": "integer"
              }
            }
          ]
        }
      }
    },
    {
      "input": {
        "kind": "pair",
        "car": {
          "kind": "string",
          "value": "runtime.not-callable"
        },
        "cdr": {
          "kind": "list",
          "items": [
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "actual"
              },
              "cdr": {
                "kind": "string",
                "value": "integer"
              }
            },
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "actual"
              },
              "cdr": {
                "kind": "string",
                "value": "pair"
              }
            }
          ]
        }
      }
    },
    {
      "input": {
        "kind": "pair",
        "car": {
          "kind": "string",
          "value": "runtime.not-callable"
        },
        "cdr": {
          "kind": "empty-list"
        }
      }
    },
    {
      "input": {
        "kind": "pair",
        "car": {
          "kind": "string",
          "value": "runtime.not-callable"
        },
        "cdr": {
          "kind": "list",
          "items": [
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "unused"
              },
              "cdr": {
                "kind": "integer",
                "value": "0"
              }
            },
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "actual"
              },
              "cdr": {
                "kind": "string",
                "value": "integer"
              }
            }
          ]
        }
      }
    },
    {
      "input": {
        "kind": "pair",
        "car": {
          "kind": "string",
          "value": "runtime.not-callable"
        },
        "cdr": {
          "kind": "list",
          "items": [
            {
              "kind": "pair",
              "car": {
                "kind": "string",
                "value": "actual"
              },
              "cdr": {
                "kind": "integer",
                "value": "7"
              }
            }
          ]
        }
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Условиеdomain.condition
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.condition",
    "data": {
      "reason": "unknown-code",
      "field": false
    }
  }
}
Условиеdomain.condition
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.condition",
    "data": {
      "reason": "terminal-code",
      "field": false
    }
  }
}
Условиеdomain.condition
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.condition",
    "data": {
      "reason": "payload-shape",
      "field": false
    }
  }
}
Условиеdomain.condition
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.condition",
    "data": {
      "reason": "payload-shape",
      "field": false
    }
  }
}
Условиеdomain.condition
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.condition",
    "data": {
      "reason": "key-type",
      "field": false
    }
  }
}
Условиеdomain.condition
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.condition",
    "data": {
      "reason": "duplicate-field",
      "field": "actual"
    }
  }
}
Условиеdomain.condition
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.condition",
    "data": {
      "reason": "missing-field",
      "field": "actual"
    }
  }
}
Условиеdomain.condition
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.condition",
    "data": {
      "reason": "extra-field",
      "field": "unused"
    }
  }
}
Условиеdomain.condition
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.condition",
    "data": {
      "reason": "field-type",
      "field": "actual"
    }
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "construction": {
    "rejectedReasons": [
      "unknown-code",
      "terminal-code",
      "payload-shape",
      "payload-shape",
      "key-type",
      "duplicate-field",
      "missing-field",
      "extra-field",
      "field-type"
    ],
    "partialConditionProduced": false,
    "guestRecoveryAllowed": true,
    "inputOrderUsedForDuplicateDetection": true,
    "canonicalKeyOrderUsedForMissingExtraAndTypes": true
  }
}
Вызов продукта

Ожидаемый результат

Unknown and terminal codes are rejected. Malformed lists, keys, repeated fields, missing fields, extra fields, and mistyped fields are separate failures. Product execution awaits its 2.0 adapter.

The request uses documentation notation. Diagnostic fields use their typed representation. This example fixes no result or receipt bytes. Product execution remains not-run.

Separate a condition from its raised site

lispex.example.v2.conditions.condition-raise-sites · ред. 1

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (guard (condition (#f 0))
        (car input))))
)
explicit-raise.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (guard (condition (else (raise condition)))
        (car input))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare each source",
    "evaluate": "finite values sufficient for each stated calculation and complete condition encoding"
  },
  "requests": [
    {
      "source": "source.scm",
      "input": {
        "kind": "empty-list"
      },
      "rootModule": "main",
      "moduleSources": [
        {
          "name": "main",
          "source": "source.scm"
        }
      ]
    },
    {
      "source": "explicit-raise.scm",
      "input": {
        "kind": "empty-list"
      },
      "rootModule": "main",
      "moduleSources": [
        {
          "name": "main",
          "source": "explicit-raise.scm"
        }
      ]
    }
  ],
  "siteNotation": {
    "original-car": "the car call in source.scm",
    "explicit-raise": "the raise call in explicit-raise.scm"
  },
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Условиеdomain.type
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.type",
    "data": {
      "operation": "car",
      "argument": "0",
      "path": [],
      "expected": "pair",
      "actual": "empty-list"
    }
  }
}
Условиеdomain.type
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.type",
    "data": {
      "operation": "car",
      "argument": "0",
      "path": [],
      "expected": "pair",
      "actual": "empty-list"
    }
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "occurrences": {
    "conditionFieldsEqual": true,
    "conditionValueHasSite": false,
    "reportedSites": [
      {
        "fixtureSite": "original-car"
      },
      {
        "fixtureSite": "explicit-raise"
      }
    ],
    "unmatchedGuardPreservesOccurrence": true,
    "explicitRaiseCreatesOccurrence": true
  }
}
Вызов продукта

Ожидаемый результат

An unmatched guard preserves the car failure site. Explicit raise reports its own site with the same condition fields. Product execution awaits its 2.0 adapter.

The request uses documentation notation. Diagnostic fields use their typed representation. This example fixes no result or receipt bytes. Product execution remains not-run.

Reject noncondition accessor and raise arguments

lispex.example.v2.conditions.condition-accessor-types · ред. 1

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (if (= input 0)
          (condition-code 7)
          (if (= input 1)
              (raise 7)
              (make-condition 7 '())))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare each source",
    "evaluate": "finite values sufficient for each stated calculation and complete condition encoding"
  },
  "requests": [
    {
      "input": {
        "kind": "integer",
        "value": "0"
      }
    },
    {
      "input": {
        "kind": "integer",
        "value": "1"
      }
    },
    {
      "input": {
        "kind": "integer",
        "value": "2"
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Условиеdomain.type
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.type",
    "data": {
      "operation": "condition-code",
      "argument": "0",
      "path": [],
      "expected": "condition",
      "actual": "integer"
    }
  }
}
Условиеdomain.type
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.type",
    "data": {
      "operation": "raise",
      "argument": "0",
      "path": [],
      "expected": "condition",
      "actual": "integer"
    }
  }
}
Условиеdomain.type
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.type",
    "data": {
      "operation": "make-condition",
      "argument": "0",
      "path": [],
      "expected": "string",
      "actual": "integer"
    }
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "validation": {
    "ordinaryTypeConditions": true,
    "implicitConditionCoercion": false,
    "implicitStringCoercion": false
  }
}
Вызов продукта

Ожидаемый результат

The accessor and raise reject an integer in place of a Condition. Construction rejects an integer in place of a code string. Product execution awaits its 2.0 adapter.

The request uses documentation notation. Diagnostic fields use their typed representation. This example fixes no result or receipt bytes. Product execution remains not-run.

Reject a Condition at the result boundary

lispex.example.v2.conditions.condition-result-boundary · ред. 1

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (guard (condition (else 0))
        (make-condition "domain.application" input))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare each source",
    "evaluate": "finite values sufficient for each stated calculation and complete condition encoding"
  },
  "requests": [
    {
      "input": {
        "kind": "list",
        "items": [
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "tag"
            },
            "cdr": {
              "kind": "string",
              "value": "invalid-input"
            }
          },
          {
            "kind": "pair",
            "car": {
              "kind": "string",
              "value": "data"
            },
            "cdr": {
              "kind": "list",
              "items": [
                {
                  "kind": "integer",
                  "value": "7"
                },
                {
                  "kind": "string",
                  "value": "field"
                }
              ]
            }
          }
        ]
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Диагностикаvalue.boundary
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "diagnostic": {
    "phase": "evaluate",
    "code": "value.boundary",
    "data": {
      "reason": "non-datum",
      "count": "1",
      "path": [],
      "actual": "condition"
    }
  },
  "canonicalOutcomeProduced": true,
  "evaluationReceiptEligible": true
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "boundary": {
    "guardCompleted": true,
    "guestRecoveryEntered": false,
    "resultDatumProduced": false
  }
}
Вызов продукта

Ожидаемый результат

The guard completes with a Condition value. Entry result validation rejects it outside guest recovery. Product execution awaits its 2.0 adapter.

The Condition value is internal. The field data remains portable. Result validation runs after the guard has completed. Product execution remains not-run.

Guard syntax

EBNF
guard = "(" "guard" "(" identifier clause* ")" body ")"
body = definition* expression+
clause = "(" test expression+ ")"
       | "(" test ")"
       | "(" test "=>" recipient ")"
       | "(" "else" expression+ ")"
test = expression
recipient = expression

Identifiers follow Source and normalization. Definitions and expressions follow Evaluation. Recursive body definitions follow the lambda initializer restriction.

Lexical guard

A lexical guard protects evaluation of its body, including calls made while that body runs. Its condition name is a lexical binding for its clauses. A matching clause computes the replacement value. Evaluation does not resume at the failed operation.

Structured raise propagates a condition. It cannot create a continuation or install a dynamic handler.

7.3 Recover from an ordinary condition

A lexical guard may catch a runtime or domain condition from its body. It abandons the failed body and returns the selected clause result. That result preserves its internal value count. The result reaches the guard expression's continuation. A body failure preserves the enclosing call's pending return. The tail-position rule governs the protected body and selected handler clause.

7.3ред. 4
lispex.rule.v2.conditions.lexical-guard

Why

A rule can handle expected input failures without reentering a failed operation or changing the execution boundary.

The enclosing continuation remains available after a body failure.

Recover from an empty pair input

lispex.example.v2.conditions.guard-recovery · ред. 1

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (guard (condition
               (else 0))
        (car input))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare this source",
    "evaluate": "finite values sufficient for the stated finite calculation"
  },
  "requests": [
    {
      "input": {
        "kind": "empty-list"
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Результат0
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "0"
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "recovery": {
    "clauseSelected": true,
    "failedOperationResumed": false
  }
}
Вызов продукта

Ожидаемый результат

The car domain condition selects the guard clause. The rule returns the exact integer 0. Product invocation awaits its 2.0 adapter.

The request uses documentation notation. The diagnostic catalog fixes condition codes. Product execution awaits its 2.0 adapter.

Return the successful body value

lispex.example.v2.conditions.guard-success · ред. 1

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (guard (condition
               (else 0))
        (car input))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare this source",
    "evaluate": "finite values sufficient for the stated finite calculation"
  },
  "requests": [
    {
      "input": {
        "kind": "list",
        "items": [
          {
            "kind": "integer",
            "value": "3"
          },
          {
            "kind": "integer",
            "value": "5"
          }
        ]
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Результат3
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "3"
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "recovery": {
    "clauseSelected": false
  }
}
Вызов продукта

Ожидаемый результат

The successful car call returns 3. The recovery clause is not evaluated. Product invocation awaits its 2.0 adapter.

The request uses documentation notation. The diagnostic catalog fixes condition codes. Product execution awaits its 2.0 adapter.

7.4 Propagate a structured condition

Structured raise signals a Condition with its stable phase, code, and data. It records the site of that explicit raise. It never resumes the operation that produced an earlier occurrence.

7.4ред. 2
lispex.rule.v2.conditions.structured-raise

Why

Explicit propagation preserves a failure that the current rule cannot handle. A resumable signal would add control behavior outside the adopted surface.

Propagate the caught condition

lispex.example.v2.conditions.raise-condition · ред. 2

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (guard (condition
               (else (raise condition)))
        (car input))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare this source",
    "evaluate": "finite values sufficient for the stated finite calculation"
  },
  "requests": [
    {
      "input": {
        "kind": "empty-list"
      }
    }
  ],
  "siteNotation": {
    "raise-site": "the explicit raise call in the recovery clause"
  },
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Условиеdomain.type
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.type",
    "data": {
      "operation": "car",
      "argument": "0",
      "path": [],
      "expected": "pair",
      "actual": "empty-list"
    }
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "propagation": {
    "conditionCodePreserved": true,
    "canonicalConditionDataPreserved": true,
    "failedOperationResumed": false,
    "conditionHasSite": false,
    "originalFailureSitePreserved": false,
    "reportedSite": {
      "fixtureSite": "raise-site"
    }
  }
}
Вызов продукта

Ожидаемый результат

The raised condition preserves the car domain code and data. The rule returns no datum. Product invocation awaits its 2.0 adapter.

The request uses documentation notation. The diagnostic catalog fixes condition codes. Product execution awaits its 2.0 adapter.

7.5 Write a complete lexical guard

A guard uses the guard grammar. A body follows the ordinary definition and expression rules.

The condition name is bound only in the clauses. Body definitions are visible only inside the body. Clauses use the surrounding lexical scope.

PartRequired behavior
Protected bodyEvaluate in source order with the guard active. Pass a normal result through unchanged.
TestEvaluate once. Require exactly one value. Only #f is false.
Test and bodyEvaluate the selected expressions in source order. Return the final result packet.
Test aloneReturn the true test value.
Test and recipientAfter a true test, evaluate the recipient once. Require exactly one procedure value. Call it with the test value.
Default clauseUse else once at most. Place it last. Its expression sequence must be nonempty.
Empty clause listPropagate the original raised occurrence outward.
Normal or selected resultPreserve zero, one, or many internal values for the enclosing context.

A clause beginning with else is the default clause. In every other clause, => in the second position marks a recipient. These markers do not depend on bindings.

Clause tests, recipients, and bodies run with the handling guard inactive. A new failure reaches an outer guard. An unmatched condition preserves its original occurrence and failure site. A terminal failure ends guest evaluation.

An arrow call uses the ordinary procedure checks. A test or recipient with a wrong value count raises the ordinary value count condition. Later clauses do not run after a match or a failure.

Preparation rejects malformed guards in source order. Each rejection has phase normalize and code syntax.form. Its fields are fixed below.

Malformed partformreason
Missing or nonidentifier condition nameguardguard-variable
Empty body or definition after an expressionguardguard-body
Empty clause or improper clause listguardclause-shape
Default clause before another clauseguardelse-position
Default clause without an expressionguardelse-body
Arrow clause without exactly one recipient expressionguardarrow-shape

The adopted propagation rule fixes clause order and outward recovery. Body and handler tail positions follow the tail-position rule. Procedure rules govern internal values and calls.

7.5ред. 3
lispex.rule.v2.conditions.guard-grammar

Why

Familiar conditional clauses express recovery without resumable control. Explicit evaluation order gives every product the same first failure. An inactive handling guard prevents recovery from catching itself. Internal value packets remain usable inside ordinary procedure composition.

Active protection and handler execution have different control lifetimes.

Select each clause form

lispex.example.v2.conditions.guard-clause-forms · ред. 1

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (guard (condition
               ((= input 0) 3 7)
               ((if (= input 1) 11 #f))
               ((if (= input 2) 13 #f) => (lambda (value) (+ value 1)))
               (else 17))
        (car '()))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare each valid source",
    "evaluate": "finite values sufficient for each stated calculation and its result encoding"
  },
  "requests": [
    {
      "input": {
        "kind": "integer",
        "value": "0"
      }
    },
    {
      "input": {
        "kind": "integer",
        "value": "1"
      }
    },
    {
      "input": {
        "kind": "integer",
        "value": "2"
      }
    },
    {
      "input": {
        "kind": "integer",
        "value": "3"
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Результат7
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "7"
  }
}
Результат11
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "11"
  }
}
Результат14
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "14"
  }
}
Результат17
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "17"
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "recovery": {
    "selectedClauses": [
      1,
      2,
      3,
      4
    ],
    "testEvaluatedOnce": true,
    "recipientEvaluatedOnlyAfterTrueTest": true,
    "unselectedBodiesEvaluated": false
  }
}
Вызов продукта

Ожидаемый результат

The four requests return 7, 11, 14, and 17. A test-only clause returns its test value. The arrow recipient receives 13. Product invocation awaits its 2.0 adapter.

The fixture states the language expectation. Its request uses documentation notation. Product execution remains not-run.

Preserve lexical scope and internal values

lispex.example.v2.conditions.guard-scope-and-values · ред. 1

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (let ((condition 7))
        (call-with-values
          (lambda ()
            (guard (condition
                     ((= input 1) (values 2 3))
                     (else (values)))
              (define normal (lambda () (values condition 5)))
              (if (= input 0) (normal) (car '()))))
          (lambda results results)))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare each valid source",
    "evaluate": "finite values sufficient for each stated calculation and its result encoding"
  },
  "requests": [
    {
      "input": {
        "kind": "integer",
        "value": "0"
      }
    },
    {
      "input": {
        "kind": "integer",
        "value": "1"
      }
    },
    {
      "input": {
        "kind": "integer",
        "value": "2"
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Результат(7 5)
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "list",
    "items": [
      {
        "kind": "integer",
        "value": "7"
      },
      {
        "kind": "integer",
        "value": "5"
      }
    ]
  }
}
Результат(2 3)
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "list",
    "items": [
      {
        "kind": "integer",
        "value": "2"
      },
      {
        "kind": "integer",
        "value": "3"
      }
    ]
  }
}
Результат()
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "empty-list"
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "scope": {
    "bodyUsesOuterConditionBinding": true,
    "conditionBindingVisibleInBody": false
  },
  "valuePackets": {
    "countsBeforeConsumer": [
      2,
      2,
      0
    ],
    "guardAddsNoValueCountCheck": true
  }
}
Вызов продукта

Ожидаемый результат

The consumer returns the lists of 7 and 5, of 2 and 3, and the empty list. The protected body sees the outer condition binding. Product invocation awaits its 2.0 adapter.

The fixture states the language expectation. Its request uses documentation notation. Product execution remains not-run.

Propagate through an empty clause list

lispex.example.v2.conditions.guard-empty-clauses · ред. 1

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (guard (outer (else 9))
        (guard (inner)
          (car input)))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare each valid source",
    "evaluate": "finite values sufficient for each stated calculation and its result encoding"
  },
  "requests": [
    {
      "input": {
        "kind": "empty-list"
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Результат9
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "9"
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "recovery": {
    "innerClauseSelected": false,
    "outerClauseSelected": true,
    "originalConditionPreserved": true,
    "originalFailureSitePreserved": true
  }
}
Вызов продукта

Ожидаемый результат

The empty inner clause list passes the original failure outward. The outer guard returns 9. Product invocation awaits its 2.0 adapter.

The fixture states the language expectation. Its request uses documentation notation. Product execution remains not-run.

Keep tests and recovery outside their guard

lispex.example.v2.conditions.guard-inactive-handling · ред. 1

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (guard (outer (else 19))
        (guard (inner
                 ((if (= input 0) (car '()) #f) 11)
                 ((= input 1) => (car '()))
                 (else (car '())))
          (car '())))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare each valid source",
    "evaluate": "finite values sufficient for each stated calculation and its result encoding"
  },
  "requests": [
    {
      "input": {
        "kind": "integer",
        "value": "0"
      }
    },
    {
      "input": {
        "kind": "integer",
        "value": "1"
      }
    },
    {
      "input": {
        "kind": "integer",
        "value": "2"
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Результат19
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "19"
  }
}
Результат19
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "19"
  }
}
Результат19
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "19"
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "recovery": {
    "failureParts": [
      "test",
      "recipient",
      "body"
    ],
    "handlingGuardReentered": false,
    "outerClauseSelected": [
      true,
      true,
      true
    ]
  }
}
Вызов продукта

Ожидаемый результат

A failing test, recipient expression, or recovery body reaches the outer guard. Each request returns 19. Product invocation awaits its 2.0 adapter.

The fixture states the language expectation. Its request uses documentation notation. Product execution remains not-run.

Require one test and recipient value

lispex.example.v2.conditions.guard-single-test-value · ред. 1

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (guard (outer (else 23))
        (guard (inner
                 ((if (= input 0) (values) #f) 1)
                 ((if (= input 1) (values 1 2) #f) 2)
                 ((= input 2) => (values))
                 ((= input 3) => (lambda () 3))
                 ((= input 4) => 0)
                 (else 29))
          (car '())))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare each valid source",
    "evaluate": "finite values sufficient for each stated calculation and its result encoding"
  },
  "requests": [
    {
      "input": {
        "kind": "integer",
        "value": "0"
      }
    },
    {
      "input": {
        "kind": "integer",
        "value": "1"
      }
    },
    {
      "input": {
        "kind": "integer",
        "value": "2"
      }
    },
    {
      "input": {
        "kind": "integer",
        "value": "3"
      }
    },
    {
      "input": {
        "kind": "integer",
        "value": "4"
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Результат23
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "23"
  }
}
Результат23
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "23"
  }
}
Результат23
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "23"
  }
}
Результат23
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "23"
  }
}
Результат23
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "23"
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "recovery": {
    "failures": [
      "zero-test-values",
      "multiple-test-values",
      "zero-recipient-values",
      "recipient-arity",
      "recipient-type"
    ],
    "handlingGuardReentered": false,
    "defaultClauseEvaluated": false,
    "outerClauseSelected": [
      true,
      true,
      true,
      true,
      true
    ]
  }
}
Вызов продукта

Ожидаемый результат

Invalid test counts, recipient counts, recipient arity, and recipient type reach the outer guard. Every request returns 23. Product invocation awaits its 2.0 adapter.

The fixture states the language expectation. Its request uses documentation notation. Product execution remains not-run.

Reject malformed guards before entry

lispex.example.v2.conditions.guard-invalid-forms · ред. 1

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule (lambda (input) (guard (condition (else 0) (#t 1)) input)))
)
else-body.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule (lambda (input) (guard (condition (else)) input)))
)
arrow-shape.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule (lambda (input) (guard (condition (#t =>)) input)))
)
guard-variable.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule (lambda (input) (guard (0 (else 1)) input)))
)
guard-body.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule (lambda (input) (guard (condition (else 1)))))
)
clause-shape.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule (lambda (input) (guard (condition ()) input)))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare each valid source",
    "evaluate": "finite values sufficient for each stated calculation and its result encoding"
  },
  "requests": [
    {
      "source": "source.scm",
      "input": {
        "kind": "integer",
        "value": "0"
      },
      "rootModule": "main",
      "moduleSources": [
        {
          "name": "main",
          "source": "source.scm"
        }
      ]
    },
    {
      "source": "else-body.scm",
      "input": {
        "kind": "integer",
        "value": "0"
      },
      "rootModule": "main",
      "moduleSources": [
        {
          "name": "main",
          "source": "else-body.scm"
        }
      ]
    },
    {
      "source": "arrow-shape.scm",
      "input": {
        "kind": "integer",
        "value": "0"
      },
      "rootModule": "main",
      "moduleSources": [
        {
          "name": "main",
          "source": "arrow-shape.scm"
        }
      ]
    },
    {
      "source": "guard-variable.scm",
      "input": {
        "kind": "integer",
        "value": "0"
      },
      "rootModule": "main",
      "moduleSources": [
        {
          "name": "main",
          "source": "guard-variable.scm"
        }
      ]
    },
    {
      "source": "guard-body.scm",
      "input": {
        "kind": "integer",
        "value": "0"
      },
      "rootModule": "main",
      "moduleSources": [
        {
          "name": "main",
          "source": "guard-body.scm"
        }
      ]
    },
    {
      "source": "clause-shape.scm",
      "input": {
        "kind": "integer",
        "value": "0"
      },
      "rootModule": "main",
      "moduleSources": [
        {
          "name": "main",
          "source": "clause-shape.scm"
        }
      ]
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Диагностикаsyntax.form
Подробности результата
{
  "kind": "prepare-failure",
  "valueCount": 0,
  "diagnostic": {
    "phase": "normalize",
    "code": "syntax.form",
    "data": {
      "form": "guard",
      "reason": "else-position"
    }
  },
  "guestControlEntered": false,
  "canonicalOutcomeProduced": false,
  "evaluationReceiptEligible": false
}
Диагностикаsyntax.form
Подробности результата
{
  "kind": "prepare-failure",
  "valueCount": 0,
  "diagnostic": {
    "phase": "normalize",
    "code": "syntax.form",
    "data": {
      "form": "guard",
      "reason": "else-body"
    }
  },
  "guestControlEntered": false,
  "canonicalOutcomeProduced": false,
  "evaluationReceiptEligible": false
}
Диагностикаsyntax.form
Подробности результата
{
  "kind": "prepare-failure",
  "valueCount": 0,
  "diagnostic": {
    "phase": "normalize",
    "code": "syntax.form",
    "data": {
      "form": "guard",
      "reason": "arrow-shape"
    }
  },
  "guestControlEntered": false,
  "canonicalOutcomeProduced": false,
  "evaluationReceiptEligible": false
}
Диагностикаsyntax.form
Подробности результата
{
  "kind": "prepare-failure",
  "valueCount": 0,
  "diagnostic": {
    "phase": "normalize",
    "code": "syntax.form",
    "data": {
      "form": "guard",
      "reason": "guard-variable"
    }
  },
  "guestControlEntered": false,
  "canonicalOutcomeProduced": false,
  "evaluationReceiptEligible": false
}
Диагностикаsyntax.form
Подробности результата
{
  "kind": "prepare-failure",
  "valueCount": 0,
  "diagnostic": {
    "phase": "normalize",
    "code": "syntax.form",
    "data": {
      "form": "guard",
      "reason": "guard-body"
    }
  },
  "guestControlEntered": false,
  "canonicalOutcomeProduced": false,
  "evaluationReceiptEligible": false
}
Диагностикаsyntax.form
Подробности результата
{
  "kind": "prepare-failure",
  "valueCount": 0,
  "diagnostic": {
    "phase": "normalize",
    "code": "syntax.form",
    "data": {
      "form": "guard",
      "reason": "clause-shape"
    }
  },
  "guestControlEntered": false,
  "canonicalOutcomeProduced": false,
  "evaluationReceiptEligible": false
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "preparation": {
    "caseOrder": [
      "source.scm",
      "else-body.scm",
      "arrow-shape.scm",
      "guard-variable.scm",
      "guard-body.scm",
      "clause-shape.scm"
    ],
    "guardEntered": false
  }
}
Вызов продукта

Ожидаемый результат

Each malformed guard fails normalization before entry. Its diagnostic identifies the first malformed guard part. Product invocation awaits its 2.0 adapter.

The fixture states the language expectation. Its request uses documentation notation. Product execution remains not-run.

7.6 Evaluate recovery outside the handling guard

Guard clauses are tested in source order. The first matching clause supplies the replacement result. An unmatched condition propagates outward. The handling guard is inactive while clause tests, recipients, and bodies run. The guard event schedule fixes failure unwinding. Selected clause tail positions follow the tail-position rule.

7.6ред. 5
lispex.rule.v2.conditions.guard-propagation

Why

A failing recovery clause must not repeatedly catch its own failure. Ordered clauses and outward propagation give nested recovery one deterministic path.

Guard clauses follow a fixed order and propagate unmatched conditions outward.

Discarding failed calls must preserve the enclosing call's pending return.

Choose the first matching clause

lispex.example.v2.conditions.guard-clause-order · ред. 2

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (guard (condition
               (#t 7)
               (else (car '())))
        (car input))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare this source",
    "evaluate": "finite values sufficient for the stated finite calculation"
  },
  "requests": [
    {
      "input": {
        "kind": "empty-list"
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Результат7
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "7"
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "recovery": {
    "selectedClause": 1,
    "laterClauseEvaluated": false
  }
}
Вызов продукта

Ожидаемый результат

The first clause matches and returns 7. The later failing clause is not evaluated. Product invocation awaits its 2.0 adapter.

The request uses documentation notation. The diagnostic catalog fixes condition codes. Product execution awaits its 2.0 adapter.

Pass an unmatched condition outward

lispex.example.v2.conditions.guard-unmatched · ред. 2

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (guard (outer (else 7))
        (guard (inner (#f 9))
          (car input)))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare this source",
    "evaluate": "finite values sufficient for the stated finite calculation"
  },
  "requests": [
    {
      "input": {
        "kind": "empty-list"
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Результат7
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "7"
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "recovery": {
    "innerClauseSelected": false,
    "outerClauseSelected": true,
    "originalConditionPreserved": true
  }
}
Вызов продукта

Ожидаемый результат

The inner guard has no matching clause. The outer guard receives the original condition and returns 7. Product invocation awaits its 2.0 adapter.

The request uses documentation notation. The diagnostic catalog fixes condition codes. Product execution awaits its 2.0 adapter.

Handle a recovery failure in the outer guard

lispex.example.v2.conditions.guard-recovery-failure · ред. 2

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (guard (outer (else 8))
        (guard (inner (else (/ 1 0)))
          (car input)))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare this source",
    "evaluate": "finite values sufficient for the stated finite calculation"
  },
  "requests": [
    {
      "input": {
        "kind": "empty-list"
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Результат8
Подробности результата
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "8"
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "recovery": {
    "innerGuardReentered": false,
    "outerClauseSelected": true,
    "outerConditionOperation": "/"
  }
}
Вызов продукта

Ожидаемый результат

Division fails in the inner recovery clause. The outer guard handles that new condition and returns 8. Product invocation awaits its 2.0 adapter.

The request uses documentation notation. The diagnostic catalog fixes condition codes. Product execution awaits its 2.0 adapter.

Terminal failures

A terminal failure returns control to the calling application. Guest guards cannot intercept preparation, admission, resource, operational, or internal failures.

Resource exhaustion preserves the first resource cause. The evaluator runs no guest recovery or cleanup after that stop. A host interruption and an engine defect stay distinct from a deterministic language failure.

7.7 Keep terminal failures outside guards

Preparation, admission, resource, operational, and internal failures end the request outside guest recovery. A resource stop preserves its first cause.

7.7ред. 3
lispex.rule.v2.conditions.terminal-boundary

Why

Recovery code must not spend resources after exhaustion or turn a rejected request into an admitted execution.

End an unending guarded calculation

lispex.example.v2.conditions.guard-resource-stop · ред. 2

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (guard (condition
               (else 99))
        (let loop ()
          (loop)))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare this source",
    "evaluate": "finite work limit with all other limits sufficient through the first work stop"
  },
  "requests": [
    {
      "input": {
        "kind": "integer",
        "value": "0"
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Результатresource-stop
Подробности результата
{
  "kind": "resource-stop",
  "valueCount": 0,
  "terminal": true,
  "diagnosticIdentity": {
    "phase": "evaluate",
    "code": "resource.exhausted"
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "recovery": {
    "clauseSelected": false,
    "guestCleanupEntered": false
  },
  "returnedControl": true
}
Вызов продукта

Ожидаемый результат

Finite work is exhausted. The resource stop remains terminal and the guard never returns 99. Product invocation awaits its 2.0 adapter.

The request uses documentation notation. The failure mapping defines its diagnostic identity selector. The failed reservation determines the typed fields. Product execution awaits its 2.0 adapter.

Reject invalid host input before the guard

lispex.example.v2.conditions.guard-admission · ред. 3

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (guard (condition (else 99)) input)))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare this source",
    "evaluate": "finite values sufficient for the stated finite calculation"
  },
  "requests": [
    {
      "input": {
        "fixtureValue": "host callback from hostSetup"
      }
    }
  ],
  "hostSetup": {
    "inputKind": "host-callback",
    "callbackResult": {
      "kind": "integer",
      "value": "42"
    }
  },
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Диагностикаinput.value
Подробности результата
{
  "kind": "admission-failure",
  "valueCount": 0,
  "diagnostic": {
    "phase": "admission",
    "code": "input.value",
    "data": {
      "actual": "host-capability",
      "path": []
    }
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "recovery": {
    "bodyEntered": false,
    "clauseSelected": false
  },
  "callbackInvocations": 0,
  "canonicalOutcomeProduced": false,
  "evaluationReceiptEligible": false
}
Вызов продукта

Ожидаемый результат

A host callback is rejected at the data boundary before guest evaluation. The guard cannot recover. Product invocation awaits its 2.0 adapter.

The request uses documentation notation. The diagnostic catalog fixes condition codes. Product execution awaits its 2.0 adapter.

Reject a removed operation before evaluation

lispex.example.v2.conditions.guard-prepare · ред. 3

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (guard (condition (else 99))
        (call/cc (lambda (exit) (exit 1))))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare this source",
    "evaluate": "finite values sufficient for the stated finite calculation"
  },
  "requests": [
    {
      "input": {
        "kind": "integer",
        "value": "0"
      }
    }
  ],
  "preparationCheck": "Reject the removed call/cc operation before guest evaluation.",
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Диагностикаlibrary.reference
Подробности результата
{
  "kind": "prepare-failure",
  "valueCount": 0,
  "diagnostic": {
    "phase": "resolve",
    "code": "library.reference",
    "data": {
      "name": "call/cc",
      "reason": "removed-operation"
    }
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "recovery": {
    "bodyEntered": false,
    "clauseSelected": false
  },
  "canonicalOutcomeProduced": false,
  "evaluationReceiptEligible": false
}
Вызов продукта

Ожидаемый результат

Preparation rejects call/cc. The body and recovery clause never run. Product invocation awaits its 2.0 adapter.

The request uses documentation notation. The diagnostic catalog fixes condition codes. Product execution awaits its 2.0 adapter.

7.8 Reject dynamic condition control

Programs cannot use procedural handlers, continuable raise, call/cc, or dynamic-wind. Preparation rejects these removed control operations. The diagnostic uses phase resolve and code library.reference. Its reason is removed-operation. Its name identifies the removed operation. The failure mapping applies the diagnostic catalog.

7.8ред. 2
lispex.rule.v2.conditions.removed-control

Why

Lexical guards and structured propagation provide the adopted recovery surface without resumable control objects or guest cleanup after a stop.

Reject a procedural handler

lispex.example.v2.conditions.procedural-handler · ред. 3

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (with-exception-handler
        (lambda (condition) 0)
        (lambda () (car input)))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare this source",
    "evaluate": "finite values sufficient for the stated finite calculation"
  },
  "requests": [
    {
      "input": {
        "kind": "integer",
        "value": "0"
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Диагностикаlibrary.reference
Подробности результата
{
  "kind": "prepare-failure",
  "valueCount": 0,
  "diagnostic": {
    "phase": "resolve",
    "code": "library.reference",
    "data": {
      "name": "with-exception-handler",
      "reason": "removed-operation"
    }
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "guestControlEntered": false,
  "canonicalOutcomeProduced": false,
  "evaluationReceiptEligible": false
}
Вызов продукта

Ожидаемый результат

Preparation rejects the procedural handler. No handler or guest body is entered. Product invocation awaits its 2.0 adapter.

The request uses documentation notation. The diagnostic catalog fixes condition codes. Product execution awaits its 2.0 adapter.

Reject a continuable signal

lispex.example.v2.conditions.continuable-raise · ред. 3

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (raise-continuable input)))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare this source",
    "evaluate": "finite values sufficient for the stated finite calculation"
  },
  "requests": [
    {
      "input": {
        "kind": "integer",
        "value": "0"
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Диагностикаlibrary.reference
Подробности результата
{
  "kind": "prepare-failure",
  "valueCount": 0,
  "diagnostic": {
    "phase": "resolve",
    "code": "library.reference",
    "data": {
      "name": "raise-continuable",
      "reason": "removed-operation"
    }
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "guestControlEntered": false,
  "canonicalOutcomeProduced": false,
  "evaluationReceiptEligible": false
}
Вызов продукта

Ожидаемый результат

Preparation rejects continuable raise. No resumable condition is created. Product invocation awaits its 2.0 adapter.

The request uses documentation notation. The diagnostic catalog fixes condition codes. Product execution awaits its 2.0 adapter.

Reject dynamic cleanup

lispex.example.v2.conditions.wind-cleanup · ред. 3

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (dynamic-wind
        (lambda () 1)
        (lambda () input)
        (lambda () 2))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare this source",
    "evaluate": "finite values sufficient for the stated finite calculation"
  },
  "requests": [
    {
      "input": {
        "kind": "integer",
        "value": "0"
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Диагностикаlibrary.reference
Подробности результата
{
  "kind": "prepare-failure",
  "valueCount": 0,
  "diagnostic": {
    "phase": "resolve",
    "code": "library.reference",
    "data": {
      "name": "dynamic-wind",
      "reason": "removed-operation"
    }
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "guestControlEntered": false,
  "canonicalOutcomeProduced": false,
  "evaluationReceiptEligible": false
}
Вызов продукта

Ожидаемый результат

Preparation rejects dynamic-wind. None of the three procedures runs. Product invocation awaits its 2.0 adapter.

The request uses documentation notation. The diagnostic catalog fixes condition codes. Product execution awaits its 2.0 adapter.

Failure order

The evaluation rules order the operator, arguments, and call checks. The resource rules order reservations at their semantic sites. A guard sees the first catchable condition reached by those events.

Later arguments do not run after an earlier argument fails. A guard may select a recovery clause. A terminal resource stop preserves its first cause.

7.9 Report the first ordered failure

A lexical guard receives the first catchable condition reached under evaluation order and resource event order. The event-preservation rule applies when optimizing that path.

7.9ред. 1
lispex.rule.v2.conditions.first-failure

Why

Pure expressions can fail in different ways. Reordering them would change which condition a guard receives and which failure the caller observes.

Keep the left argument failure first

lispex.example.v2.conditions.first-argument-failure · ред. 2

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (list (car '()) (/ 1 0))))
)
Запрос и файлы
request.json
{
  "notation": "documentation-request",
  "source": "source.scm",
  "semantics": {
    "language": "Lispex 2.0",
    "standardLibrary": "one fixed library identity",
    "unicode": "one fixed Unicode semantics version",
    "resourceModel": "one fixed finite resource model"
  },
  "limits": {
    "prepare": "finite values sufficient to prepare this source",
    "evaluate": "finite values sufficient through the first domain failure and its encoding"
  },
  "requests": [
    {
      "input": {
        "kind": "integer",
        "value": "0"
      }
    },
    {
      "input": {
        "kind": "integer",
        "value": "0"
      }
    }
  ],
  "executionContexts": [
    "unoptimized engine path",
    "optimized engine path"
  ],
  "siteNotation": {
    "left-car": "the car call in the first list argument"
  },
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
Результат по спецификации
Условиеdomain.type
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.type",
    "data": {
      "operation": "car",
      "argument": "0",
      "path": [],
      "expected": "pair",
      "actual": "empty-list"
    }
  }
}
Условиеdomain.type
Подробности результата
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.type",
    "data": {
      "operation": "car",
      "argument": "0",
      "path": [],
      "expected": "pair",
      "actual": "empty-list"
    }
  }
}

Результат по спецификации. Запуски продукта ожидают адаптера 2.0.

Подробности семантики
{
  "comparison": {
    "canonicalOutcomeEqual": true,
    "canonicalFailureSiteEqual": true,
    "firstFailureSite": {
      "fixtureSite": "left-car"
    },
    "laterDivisionEvaluated": false
  }
}
Вызов продукта

Ожидаемый результат

Both paths report the car domain failure in the left argument. The division is never evaluated. Product invocation awaits its 2.0 adapter.

The fixture label selects the first car call. Canonical sites define its encoded location. Products never serialize the fixture label. Product execution remains not-run.

Related chapters

Evaluation and bindings

Resources

Diagnostics