본문으로 이동
(Lispex)2.0명세 · 출시 전

문서 검색

영어 명세를 검색합니다

질문, 심볼, 진단 코드, 명령을 입력하세요.

차례

명세 검색
리스펙스 2.0 · 언어 · I.4장

I.4장

Exact numbers

Calculate with exact integers, rational numbers, and decimals. Choose scale and rounding explicitly and keep numeric work within finite limits.

번역이 없는 문장은 영어 원문으로 보입니다

Scope

This chapter defines exact numeric values, division, scale, and rounding. It also describes the resource obligations of growing numeric values. Source and normalization owns literal syntax. Values and text owns scalar and structural equality.

Number values

An exact integer has no fractional part. An exact rational denotes a quotient of integers with a nonzero denominator. A reduced rational has a positive denominator and no common factor between its numerator and denominator.

An exact decimal is source notation for an exact integer or reduced rational. The spelling 0.1 denotes one tenth. A decimal point does not request an inexact number. Trailing decimal zeros do not create an observable scale on the numeric value.

Numeric values are immutable scalars. The notation used in these examples describes values and does not specify codec bytes or product output formatting.

4.1 Preserve exact numeric meaning

Integers, rational numbers, and decimal literals denote exact values. A successful arithmetic operation returns its exact mathematical result. It does not introduce binary floating point or perform implicit rounding.

Why

Rules can compare amounts and ratios without depending on a platform math library or a hidden precision setting. A decimal literal expresses the stated value exactly.

Add exact decimal values

lispex.example.v2.numbers.decimal-sum · 1판

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (= (+ 0.1 0.2) 3/10)))
)
요청과 파일
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": []
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
명세상 결과
결과#t
결과 상세
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "boolean",
    "value": true
  }
}

명세상 결과입니다. 2.0 어댑터가 준비되면 제품에서 실행합니다.

제품 실행

예상 결과

The comparison returns true because the exact sum of 0.1 and 0.2 is three tenths. Product invocation awaits its 2.0 adapter.

The Boolean expectation fixes the mathematical value without choosing a decimal result representation or displayed spelling.

4.2 Reduce rational values

A rational value is reduced to coprime numerator and denominator with a positive denominator. A negative sign belongs to the numerator. Equivalent fractions denote the same exact mathematical value.

Why

A reduced form gives each nonintegral fraction one mathematical description. It prevents unreduced source spellings from becoming different numeric values.

Reduce a fraction and preserve its sign

lispex.example.v2.numbers.rational-reduction · 1판

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (denominator)
      (/ 6 denominator)))
)
요청과 파일
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": "8"
      }
    },
    {
      "input": {
        "kind": "integer",
        "value": "-8"
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
명세상 결과
결과3/4
결과 상세
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "rational",
    "numerator": "3",
    "denominator": "4"
  }
}
결과-3/4
결과 상세
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "rational",
    "numerator": "-3",
    "denominator": "4"
  }
}

명세상 결과입니다. 2.0 어댑터가 준비되면 제품에서 실행합니다.

제품 실행

예상 결과

The two requests return the reduced rationals three quarters and negative three quarters. Both denominators are positive. Product invocation awaits its 2.0 adapter.

The numerator and denominator fields are documentation notation for the reduced values. They do not choose a serialized rational format.

4.3 Compare exact mathematical values

Numeric equality and ordering compare exact mathematical values. A decimal spelling and a rational spelling for the same value compare numerically equal. Ordering must not round either operand through a host numeric format.

Why

Rules need stable comparisons near boundaries. Comparing exact values prevents an approximation from merging unequal amounts or separating equal ones.

Compare ratios and decimal spellings

lispex.example.v2.numbers.numeric-value-comparisons · 1판

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (list (= 1.5 3/2)
            (= 0.30 3/10)
            (< 1/3 0.34)
            (= 1/3 0.33))))
)
요청과 파일
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": []
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
명세상 결과
결과(#t #t #t #f)
결과 상세
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "list",
    "items": [
      {
        "kind": "boolean",
        "value": true
      },
      {
        "kind": "boolean",
        "value": true
      },
      {
        "kind": "boolean",
        "value": true
      },
      {
        "kind": "boolean",
        "value": false
      }
    ]
  }
}

명세상 결과입니다. 2.0 어댑터가 준비되면 제품에서 실행합니다.

제품 실행

예상 결과

The comparisons return true, true, true, and false in order. One third is greater than 0.33 and less than 0.34. Product invocation awaits its 2.0 adapter.

The extra decimal zero does not change the numeric value. The scalar comparison case also checks that decimal source scale is not observable.

4.4 Give decimal spellings exact numeric values

A decimal literal denotes an exact integer or reduced rational. Its source scale is not observable as numeric state. Mixed arithmetic uses these exact values. The scalar procedures eq? and eqv? compare their mathematical values across numeric spellings. A decimal scale needed for rounding must be supplied explicitly.

Why

One mathematical value should not acquire a hidden scale from its source spelling. Using integer and reduced-rational values keeps decimal notation exact while making a rounding policy a separate explicit choice.

Source scale is unobservable.

Return the values denoted by decimal spellings

lispex.example.v2.numbers.decimal-result-values · 2판

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (choose-sum)
      (if choose-sum
          (+ 0.1 0.2)
          1.00)))
)
요청과 파일
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": "boolean",
        "value": true
      }
    },
    {
      "input": {
        "kind": "boolean",
        "value": false
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
명세상 결과
결과3/10
결과 상세
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "rational",
    "numerator": "3",
    "denominator": "10"
  }
}
결과1
결과 상세
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "1"
  }
}

명세상 결과입니다. 2.0 어댑터가 준비되면 제품에서 실행합니다.

제품 실행

예상 결과

The decimal sum returns the reduced rational three tenths. The literal 1.00 returns the exact integer one. Product invocation awaits its 2.0 adapter.

The two requests exercise nonintegral and integral decimal values. These value descriptions select mathematical kinds without freezing serialized codec tags or displayed spellings.

Compare numeric values across spellings

lispex.example.v2.numbers.scalar-number-spellings · 2판

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (list (eq? 1 1.00)
            (eqv? 3/2 1.5)
            (eq? 0.30 3/10)
            (eqv? 1/3 0.33))))
)
요청과 파일
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": []
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
명세상 결과
결과(#t #t #t #f)
결과 상세
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "list",
    "items": [
      {
        "kind": "boolean",
        "value": true
      },
      {
        "kind": "boolean",
        "value": true
      },
      {
        "kind": "boolean",
        "value": true
      },
      {
        "kind": "boolean",
        "value": false
      }
    ]
  }
}

명세상 결과입니다. 2.0 어댑터가 준비되면 제품에서 실행합니다.

제품 실행

예상 결과

The scalar comparisons return true, true, true, and false. Decimal scale in source does not distinguish equal numeric values. Product invocation awaits its 2.0 adapter.

The last comparison stays false because one third and thirty-three hundredths are different exact values. No precision setting can make them equal.

4.5 Reject inexact numeric values

The language has no inexact numeric value kind. Inexact literals, floating point inputs, and requests for implicit inexact conversion must be rejected. A product cannot approximate a value and report a successful exact result.

Why

Keeping one exact numeric meaning removes host floating point behavior from rule outcomes. Rejection makes an unsupported numeric request visible.

Reject an explicit inexact literal

lispex.example.v2.numbers.inexact-literal-rejected · 3판

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      #i0.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": "list",
        "items": []
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
명세상 결과
진단source.token
결과 상세
{
  "kind": "prepare-failure",
  "valueCount": 0,
  "diagnostic": {
    "phase": "read",
    "code": "source.token",
    "data": {
      "reason": "unsupported-reader-prefix"
    }
  }
}

명세상 결과입니다. 2.0 어댑터가 준비되면 제품에서 실행합니다.

의미 상세
{
  "entryEvaluated": false,
  "inexactValueCreated": false,
  "canonicalOutcomeProduced": false,
  "evaluationReceiptEligible": false
}
제품 실행

예상 결과

Preparation rejects the explicit inexact literal before the entry is evaluated. No inexact value or result datum is created. Product invocation awaits its 2.0 adapter.

This is a rejection example. Removing the inexact marker changes the source request to the exact decimal value. The concrete preparation code belongs to the diagnostic catalog.

Division

Exact division can produce a rational that has no finite decimal expansion. That value remains exact. A caller that needs a finite decimal scale must request an explicit rounding operation.

A zero divisor is a language domain failure. It does not produce infinity, an inexact value, or a successful result. Conditions defines how a rule handles ordinary language failures.

4.6 Keep a quotient exact and reject zero divisors

Division by a nonzero exact number preserves the exact quotient. A quotient need not have a finite decimal expansion. Division by zero produces domain.division-by-zero and returns no result datum.

Why

A repeating decimal is still an exact rational. Keeping that value avoids a hidden precision choice. Zero division has a defined failure cause instead of an inexact special value.

Keep one third exact and reject division by zero

lispex.example.v2.numbers.division-cases · 2판

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (denominator)
      (/ 1 denominator)))
)
요청과 파일
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": "3"
      }
    },
    {
      "input": {
        "kind": "integer",
        "value": "0"
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
명세상 결과
결과1/3
결과 상세
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "rational",
    "numerator": "1",
    "denominator": "3"
  }
}
조건domain.division-by-zero
결과 상세
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.division-by-zero",
    "data": {
      "operation": "/",
      "argument": "1"
    }
  }
}

명세상 결과입니다. 2.0 어댑터가 준비되면 제품에서 실행합니다.

제품 실행

예상 결과

The first request returns the exact rational one third. The second produces a division-by-zero domain failure and no result datum. Product invocation awaits its 2.0 adapter.

The same prepared source receives two separate inputs. Neither request needs a decimal precision setting.

Scale and rounding

A decimal scale specifies the place at which a value is rounded. Scale one uses tenths and scale two uses hundredths. Scale zero uses integers. Negative scales use decimal multiples. The exact numeric value does not preserve display scale.

Quantize receives its scale and mode explicitly. The named integer procedures fix their direction and scale zero. The public catalog lists their complete procedure contracts.

4.7 Choose scale and rounding explicitly

An operation that rounds an exact number must identify its decimal scale and rounding mode in the program or input. Quantize takes both as arguments. The names floor, ceiling, and truncate identify fixed scale-zero policies. Ordinary exact arithmetic does not apply rounding implicitly. Host settings cannot choose the scale or mode.

Why

Different scales and rounding modes answer different questions about the same amount. Making the policy explicit lets the same rule reproduce that choice.

Choose tenths and hundredths in ordinary rule code

lispex.example.v2.numbers.chosen-rounding-scales · 1판

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define round-down
    (lambda (amount factor)
      (let loop ((units 0))
        (if (< amount (/ (+ units 1) factor))
            (/ units factor)
            (loop (+ units 1))))))

  (define rule
    (lambda (amount)
      (list (round-down amount 10)
            (round-down amount 100))))
)
요청과 파일
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": "rational",
        "numerator": "5",
        "denominator": "4"
      }
    }
  ],
  "roundingPolicy": {
    "domain": "nonnegative exact inputs",
    "mode": "toward negative infinity",
    "scales": [
      "one fractional decimal place",
      "two fractional decimal places"
    ]
  },
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
명세상 결과
결과(6/5 5/4)
결과 상세
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "list",
    "items": [
      {
        "kind": "rational",
        "numerator": "6",
        "denominator": "5"
      },
      {
        "kind": "rational",
        "numerator": "5",
        "denominator": "4"
      }
    ]
  }
}

명세상 결과입니다. 2.0 어댑터가 준비되면 제품에서 실행합니다.

제품 실행

예상 결과

For the nonnegative input five quarters, rounding down to tenths returns six fifths. Rounding down to hundredths preserves five quarters. Product invocation awaits its 2.0 adapter.

This fixture implements downward rounding for nonnegative inputs with exact arithmetic. The factors ten and one hundred select the two scales explicitly. The public quantize procedure expresses the same policies with scale and mode arguments.

4.8 Round on an explicit decimal grid

The public rounding procedures use exact arithmetic. Every exact integer is an admitted scale. A scale has no host word bound. Finite evaluation limits govern the required work and storage.

Procedure formArgument domainResult
(quantize x scale mode)Exact number, exact integer, and a listed mode symbolSelected exact grid value
(floor x)One exact numberGreatest integer no greater than the input
(ceiling x)One exact numberLeast integer no less than the input
(truncate x)One exact numberInteger part toward zero

Quantize requires all its arguments. The unary procedures fix scale zero and select the mode named by the procedure. They are separate procedures with the stated unary signatures.

NameExact definition
q10^(-scale)
yx / q
nInteger selected from y by the mode rule
Resultn * q

Positive scales select decimal fractions. Negative scales select decimal multiples. An integral result is an integer. Other results are reduced rationals with positive denominators. Zero is the integer zero. The result retains neither display scale nor a zero sign.

Why

An integer scale describes the grid independently of host precision. Exact results preserve the adopted numeric value model. Named integer procedures express their fixed policy without a hidden default.

Use positive and negative decimal scales

lispex.example.v2.numbers.quantize-scales · 1판

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (list (quantize 149/100 1 'floor)
            (quantize 149/100 2 'exact)
            (quantize 1250 -2 'half-even)
            (quantize 1350 -2 'half-even)
            (quantize -1250 -2 'half-even)
            (quantize -1350 -2 'half-even)
            (quantize -149 -1 'floor)
            (quantize -149 -1 'ceiling)
            (quantize 3 2 'exact))))
)
요청과 파일
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": []
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
명세상 결과
결과(7/5 149/100 1200 1400 -1200 -1400 -150 -140 3)
결과 상세
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "list",
    "items": [
      {
        "kind": "rational",
        "numerator": "7",
        "denominator": "5"
      },
      {
        "kind": "rational",
        "numerator": "149",
        "denominator": "100"
      },
      {
        "kind": "integer",
        "value": "1200"
      },
      {
        "kind": "integer",
        "value": "1400"
      },
      {
        "kind": "integer",
        "value": "-1200"
      },
      {
        "kind": "integer",
        "value": "-1400"
      },
      {
        "kind": "integer",
        "value": "-150"
      },
      {
        "kind": "integer",
        "value": "-140"
      },
      {
        "kind": "integer",
        "value": "3"
      }
    ]
  }
}

명세상 결과입니다. 2.0 어댑터가 준비되면 제품에서 실행합니다.

제품 실행

예상 결과

The results preserve the exact decimal grid for tenths, hundredths, tens, and hundreds. Integral results use integer values. Product invocation awaits its 2.0 adapter.

Negative scales round to decimal multiples. Half-even uses parity after scaling. The final value three has no stored display scale.

Use the named integer rounding procedures

lispex.example.v2.numbers.integer-rounding-procedures · 1판

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (list (floor 7/4)
            (ceiling 7/4)
            (truncate 7/4)
            (floor -7/4)
            (ceiling -7/4)
            (truncate -7/4)
            (floor 2)
            (ceiling 0)
            (truncate 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 for the stated finite calculation"
  },
  "requests": [
    {
      "input": {
        "kind": "list",
        "items": []
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
명세상 결과
결과(1 2 1 -2 -1 -1 2 0 0)
결과 상세
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "list",
    "items": [
      {
        "kind": "integer",
        "value": "1"
      },
      {
        "kind": "integer",
        "value": "2"
      },
      {
        "kind": "integer",
        "value": "1"
      },
      {
        "kind": "integer",
        "value": "-2"
      },
      {
        "kind": "integer",
        "value": "-1"
      },
      {
        "kind": "integer",
        "value": "-1"
      },
      {
        "kind": "integer",
        "value": "2"
      },
      {
        "kind": "integer",
        "value": "0"
      },
      {
        "kind": "integer",
        "value": "0"
      }
    ]
  }
}

명세상 결과입니다. 2.0 어댑터가 준비되면 제품에서 실행합니다.

제품 실행

예상 결과

The named procedures return exact integers using their fixed scale-zero direction. Product invocation awaits its 2.0 adapter.

The procedure name supplies the policy. Each unary result equals quantize at scale zero with the corresponding explicit mode.

4.9 Select a rounding mode and resolve every tie

Mode symbols match the exact spellings below. Case folding and symbol aliases do not apply. An integral scaled value selects itself in every mode.

NameDefinition for a nonintegral scaled value
aGreatest integer less than y
ba + 1
ty - a
Nearest without a tieSelect a when t < 1/2 and b when t > 1/2
Mode symbolSelected integerTie at t = 1/2
flooraa
ceilingbb
truncatea for positive y and b for negative ySame sign rule
away-from-zerob for positive y and a for negative ySame sign rule
half-evenNearest without a tieThe even integer among a and b
half-away-from-zeroNearest without a tieb for positive y and a for negative y
half-toward-zeroNearest without a tiea for positive y and b for negative y
exactdomain.numeric with rounding-requireddomain.numeric with rounding-required

Distance and tie tests use exact arithmetic. The exact mode succeeds only when the input already lies on the grid. A host rounding mode, locale, or numeric library cannot change this selection.

Why

Directed modes serve explicit lower and upper bounds. Nearest modes state their tie policy for both signs. The exact mode lets a rule require lossless quantization.

Apply every directed mode to both signs

lispex.example.v2.numbers.directed-rounding-signs · 1판

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (list (quantize 7/4 0 'floor)
            (quantize 7/4 0 'ceiling)
            (quantize 7/4 0 'truncate)
            (quantize 7/4 0 'away-from-zero)
            (quantize -7/4 0 'floor)
            (quantize -7/4 0 'ceiling)
            (quantize -7/4 0 'truncate)
            (quantize -7/4 0 'away-from-zero))))
)
요청과 파일
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": []
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
명세상 결과
결과(1 2 1 2 -2 -1 -1 -2)
결과 상세
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "list",
    "items": [
      {
        "kind": "integer",
        "value": "1"
      },
      {
        "kind": "integer",
        "value": "2"
      },
      {
        "kind": "integer",
        "value": "1"
      },
      {
        "kind": "integer",
        "value": "2"
      },
      {
        "kind": "integer",
        "value": "-2"
      },
      {
        "kind": "integer",
        "value": "-1"
      },
      {
        "kind": "integer",
        "value": "-1"
      },
      {
        "kind": "integer",
        "value": "-2"
      }
    ]
  }
}

명세상 결과입니다. 2.0 어댑터가 준비되면 제품에서 실행합니다.

제품 실행

예상 결과

Positive inputs produce one, two, one, and two. Negative inputs produce minus two, minus one, minus one, and minus two. Product invocation awaits its 2.0 adapter.

The same explicit mode applies to each sign. Directed modes do not inspect a host rounding setting.

Resolve nearest ties and normalize zero

lispex.example.v2.numbers.rounding-ties · 1판

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (list (quantize 1/2 0 'half-even)
            (quantize 1/2 0 'half-away-from-zero)
            (quantize 1/2 0 'half-toward-zero)
            (quantize -1/2 0 'half-even)
            (quantize -1/2 0 'half-away-from-zero)
            (quantize -1/2 0 'half-toward-zero)
            (quantize 3/2 0 'half-even)
            (quantize 3/2 0 'half-away-from-zero)
            (quantize 3/2 0 'half-toward-zero)
            (quantize -3/2 0 'half-even)
            (quantize -3/2 0 'half-away-from-zero)
            (quantize -3/2 0 'half-toward-zero)
            (quantize 5/4 1 'half-even)
            (quantize 5/4 1 'half-away-from-zero)
            (quantize -5/4 1 'half-toward-zero))))
)
요청과 파일
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": []
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
명세상 결과
결과(0 1 0 0 -1 0 2 2 1 -2 -2 -1 6/5 13/10 -6/5)
결과 상세
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "list",
    "items": [
      {
        "kind": "integer",
        "value": "0"
      },
      {
        "kind": "integer",
        "value": "1"
      },
      {
        "kind": "integer",
        "value": "0"
      },
      {
        "kind": "integer",
        "value": "0"
      },
      {
        "kind": "integer",
        "value": "-1"
      },
      {
        "kind": "integer",
        "value": "0"
      },
      {
        "kind": "integer",
        "value": "2"
      },
      {
        "kind": "integer",
        "value": "2"
      },
      {
        "kind": "integer",
        "value": "1"
      },
      {
        "kind": "integer",
        "value": "-2"
      },
      {
        "kind": "integer",
        "value": "-2"
      },
      {
        "kind": "integer",
        "value": "-1"
      },
      {
        "kind": "rational",
        "numerator": "6",
        "denominator": "5"
      },
      {
        "kind": "rational",
        "numerator": "13",
        "denominator": "10"
      },
      {
        "kind": "rational",
        "numerator": "-6",
        "denominator": "5"
      }
    ]
  }
}

명세상 결과입니다. 2.0 어댑터가 준비되면 제품에서 실행합니다.

제품 실행

예상 결과

Each tie follows its named policy for both signs. Every result at zero is the same integer zero. Product invocation awaits its 2.0 adapter.

The first twelve values cover both neighboring parities. The final three ties use a fractional decimal grid.

Choose the closest grid point away from ties

lispex.example.v2.numbers.nearest-rounding-nonties · 1판

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (list (quantize 7/5 0 'half-even)
            (quantize 7/5 0 'half-away-from-zero)
            (quantize 7/5 0 'half-toward-zero)
            (quantize -7/5 0 'half-even)
            (quantize -7/5 0 'half-away-from-zero)
            (quantize -7/5 0 'half-toward-zero)
            (quantize 8/5 0 'half-even)
            (quantize 8/5 0 'half-away-from-zero)
            (quantize 8/5 0 'half-toward-zero)
            (quantize -8/5 0 'half-even)
            (quantize -8/5 0 'half-away-from-zero)
            (quantize -8/5 0 'half-toward-zero))))
)
요청과 파일
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": []
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
명세상 결과
결과(1 1 1 -1 -1 -1 2 2 2 -2 -2 -2)
결과 상세
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "list",
    "items": [
      {
        "kind": "integer",
        "value": "1"
      },
      {
        "kind": "integer",
        "value": "1"
      },
      {
        "kind": "integer",
        "value": "1"
      },
      {
        "kind": "integer",
        "value": "-1"
      },
      {
        "kind": "integer",
        "value": "-1"
      },
      {
        "kind": "integer",
        "value": "-1"
      },
      {
        "kind": "integer",
        "value": "2"
      },
      {
        "kind": "integer",
        "value": "2"
      },
      {
        "kind": "integer",
        "value": "2"
      },
      {
        "kind": "integer",
        "value": "-2"
      },
      {
        "kind": "integer",
        "value": "-2"
      },
      {
        "kind": "integer",
        "value": "-2"
      }
    ]
  }
}

명세상 결과입니다. 2.0 어댑터가 준비되면 제품에서 실행합니다.

제품 실행

예상 결과

All nearest modes choose the same closest integer when the scaled distance is not a tie. Product invocation awaits its 2.0 adapter.

The cases cover both sides of a half and both signs. The three nearest modes differ only at exact ties.

Require a value already on the selected grid

lispex.example.v2.numbers.quantize-exact-grid · 2판

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (quantize (car input) (car (cdr input)) 'exact)))
)
요청과 파일
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": "rational",
            "numerator": "5",
            "denominator": "4"
          },
          {
            "kind": "integer",
            "value": "2"
          }
        ]
      }
    },
    {
      "input": {
        "kind": "list",
        "items": [
          {
            "kind": "rational",
            "numerator": "5",
            "denominator": "4"
          },
          {
            "kind": "integer",
            "value": "1"
          }
        ]
      }
    },
    {
      "input": {
        "kind": "list",
        "items": [
          {
            "kind": "integer",
            "value": "1000"
          },
          {
            "kind": "integer",
            "value": "-3"
          }
        ]
      }
    },
    {
      "input": {
        "kind": "list",
        "items": [
          {
            "kind": "integer",
            "value": "1"
          },
          {
            "kind": "integer",
            "value": "-1"
          }
        ]
      }
    },
    {
      "input": {
        "kind": "list",
        "items": [
          {
            "kind": "integer",
            "value": "0"
          },
          {
            "kind": "integer",
            "value": "3"
          }
        ]
      }
    },
    {
      "input": {
        "kind": "list",
        "items": [
          {
            "kind": "integer",
            "value": "0"
          },
          {
            "kind": "integer",
            "value": "-3"
          }
        ]
      }
    },
    {
      "input": {
        "kind": "list",
        "items": [
          {
            "kind": "integer",
            "value": "2"
          },
          {
            "kind": "integer",
            "value": "2"
          }
        ]
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
명세상 결과
결과5/4
결과 상세
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "rational",
    "numerator": "5",
    "denominator": "4"
  }
}
조건domain.numeric
결과 상세
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.numeric",
    "data": {
      "operation": "quantize",
      "argument": "0",
      "reason": "rounding-required"
    }
  }
}
결과1000
결과 상세
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "1000"
  }
}
조건domain.numeric
결과 상세
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.numeric",
    "data": {
      "operation": "quantize",
      "argument": "0",
      "reason": "rounding-required"
    }
  }
}
결과0
결과 상세
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "0"
  }
}
결과0
결과 상세
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "0"
  }
}
결과2
결과 상세
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "2"
  }
}

명세상 결과입니다. 2.0 어댑터가 준비되면 제품에서 실행합니다.

제품 실행

예상 결과

The exact mode preserves grid values and rejects both off-grid requests with a rounding-required domain failure. Product invocation awaits its 2.0 adapter.

Lossless quantization preserves mathematical values. An exact integer result stays an integer even at a positive scale.

4.10 Check rounding arguments before numeric work

Operator and operand evaluation follows the call order. An operand failure ends that evaluation before procedure checks. After operand evaluation, check arity before checking argument domains. Quantize checks the number, scale, and mode in that order. Unary rounding checks its single exact number.

CheckFailure
Quantize receives exactly three argumentsruntime.arity
A unary rounding procedure receives exactly one argumentruntime.arity
The number is exact numeric datadomain.type with expected type number
The scale is an exact integerdomain.type with expected type integer
The mode is one listed symboldomain.type for a non-symbol. domain.numeric with invalid-rounding-mode for an unlisted symbol
The exact mode input lies on the griddomain.numeric with rounding-required

After arity succeeds, the operation follows the event order below. Argument checks repeat in argument order. Unary procedures have no synthetic scale or mode argument checks.

EventWork governed by the event
argument-checkValidate the current argument domain
decimal-scaleForm the exact grid step from the scale
exact-divideForm the scaled value and adjacent integer candidates
rounding-selectSelect an integer or report rounding-required
rational-reduceForm and reduce the exact result
datum-allocateReserve and create the result datum

Each event applies reservation before effect. It uses the fixed resource axis order. The first domain failure or refused reservation ends the call. Later events do not run. A refusal returns no rounded substitute or partial datum. Successful grid points and zero still follow the declared event stages. Optimization preserves their semantic charges and first failure.

These names identify operation families. The resource event catalog defines their reservation points and canonical sites. The selected resource model supplies their requirement vectors. Resource coefficients and limits remain under the cost model freeze decision.

Why

Validation order fixes which invalid argument a program observes. Reserving numeric work before its effect keeps enormous scales within finite execution. A failed call cannot silently replace the requested policy with an approximation.

Reject invalid rounding calls in the declared order

lispex.example.v2.numbers.quantize-validation-order · 2판

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (arguments)
      (apply quantize arguments)))
)
요청과 파일
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": []
      }
    },
    {
      "input": {
        "kind": "list",
        "items": [
          {
            "kind": "string",
            "value": "bad"
          },
          {
            "kind": "integer",
            "value": "0"
          }
        ]
      }
    },
    {
      "input": {
        "kind": "list",
        "items": [
          {
            "kind": "integer",
            "value": "1"
          },
          {
            "kind": "integer",
            "value": "0"
          },
          {
            "kind": "symbol",
            "value": "half-even"
          },
          {
            "kind": "integer",
            "value": "9"
          }
        ]
      }
    },
    {
      "input": {
        "kind": "list",
        "items": [
          {
            "kind": "string",
            "value": "bad"
          },
          {
            "kind": "rational",
            "numerator": "1",
            "denominator": "2"
          },
          {
            "kind": "string",
            "value": "bad"
          }
        ]
      }
    },
    {
      "input": {
        "kind": "list",
        "items": [
          {
            "kind": "integer",
            "value": "1"
          },
          {
            "kind": "rational",
            "numerator": "1",
            "denominator": "2"
          },
          {
            "kind": "string",
            "value": "bad"
          }
        ]
      }
    },
    {
      "input": {
        "kind": "list",
        "items": [
          {
            "kind": "integer",
            "value": "1"
          },
          {
            "kind": "integer",
            "value": "0"
          },
          {
            "kind": "string",
            "value": "half-even"
          }
        ]
      }
    },
    {
      "input": {
        "kind": "list",
        "items": [
          {
            "kind": "integer",
            "value": "1"
          },
          {
            "kind": "integer",
            "value": "0"
          },
          {
            "kind": "symbol",
            "value": "HALF-EVEN"
          }
        ]
      }
    },
    {
      "input": {
        "kind": "list",
        "items": [
          {
            "kind": "integer",
            "value": "1"
          },
          {
            "kind": "integer",
            "value": "0"
          },
          {
            "kind": "symbol",
            "value": "unknown"
          }
        ]
      }
    },
    {
      "input": {
        "kind": "list",
        "items": [
          {
            "kind": "integer",
            "value": "1"
          },
          {
            "kind": "integer",
            "value": "0"
          },
          {
            "kind": "symbol",
            "value": "half-even"
          }
        ]
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
명세상 결과
조건runtime.arity
결과 상세
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "runtime.arity",
    "data": {
      "minimum": "3",
      "maximum": "3",
      "actual": "0"
    }
  }
}
조건runtime.arity
결과 상세
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "runtime.arity",
    "data": {
      "minimum": "3",
      "maximum": "3",
      "actual": "2"
    }
  }
}
조건runtime.arity
결과 상세
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "runtime.arity",
    "data": {
      "minimum": "3",
      "maximum": "3",
      "actual": "4"
    }
  }
}
조건domain.type
결과 상세
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.type",
    "data": {
      "operation": "quantize",
      "argument": "0",
      "path": [],
      "expected": "number",
      "actual": "string"
    }
  }
}
조건domain.type
결과 상세
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.type",
    "data": {
      "operation": "quantize",
      "argument": "1",
      "path": [],
      "expected": "integer",
      "actual": "rational"
    }
  }
}
조건domain.type
결과 상세
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.type",
    "data": {
      "operation": "quantize",
      "argument": "2",
      "path": [],
      "expected": "rounding-mode",
      "actual": "string"
    }
  }
}
조건domain.numeric
결과 상세
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.numeric",
    "data": {
      "operation": "quantize",
      "argument": "2",
      "reason": "invalid-rounding-mode"
    }
  }
}
조건domain.numeric
결과 상세
{
  "kind": "language-failure",
  "valueCount": 0,
  "condition": {
    "phase": "evaluate",
    "code": "domain.numeric",
    "data": {
      "operation": "quantize",
      "argument": "2",
      "reason": "invalid-rounding-mode"
    }
  }
}
결과1
결과 상세
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "1"
  }
}

명세상 결과입니다. 2.0 어댑터가 준비되면 제품에서 실행합니다.

제품 실행

예상 결과

Arity failures precede domain checks. The number, scale, and mode checks then select the first invalid argument. Product invocation awaits its 2.0 adapter.

Mode strings and differently cased symbols are invalid. Numeric calculation begins only after every argument check succeeds.

Observe an operand failure before rounding arity

lispex.example.v2.numbers.rounding-operand-before-arity · 2판

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (quantize (car '()) 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 for the stated finite calculation"
  },
  "requests": [
    {
      "input": {
        "kind": "list",
        "items": []
      }
    }
  ],
  "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 어댑터가 준비되면 제품에서 실행합니다.

제품 실행

예상 결과

The car operand fails before the missing mode can produce a quantize arity failure. Product invocation awaits its 2.0 adapter.

This case applies the existing operator and operand evaluation order to the new procedure.

Reserve rounding work before selecting a result

lispex.example.v2.numbers.rounding-resource-stop · 2판

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (quantize 1/3 2 'exact)))
)
요청과 파일
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 that admit the preceding events and refuse work at rounding-select"
  },
  "requests": [
    {
      "input": {
        "kind": "list",
        "items": []
      }
    }
  ],
  "resourceBoundary": {
    "event": "rounding-select",
    "axis": "work",
    "earlierReservations": "succeed",
    "selectedReservation": "insufficient remaining capacity"
  },
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
명세상 결과
결과resource-stop
결과 상세
{
  "kind": "resource-stop",
  "valueCount": 0,
  "terminal": true,
  "operation": "quantize",
  "event": "rounding-select",
  "diagnosticIdentity": {
    "phase": "evaluate",
    "code": "resource.exhausted"
  }
}

명세상 결과입니다. 2.0 어댑터가 준비되면 제품에서 실행합니다.

의미 상세
{
  "roundingConditionProduced": false,
  "approximationFallback": false,
  "partialResult": false
}
제품 실행

예상 결과

The declared rounding-select reservation fails before the exact mode can report rounding-required. Product invocation awaits its 2.0 adapter.

The request names a symbolic resource boundary. Numeric tariff coefficients and finite limit values remain with the resource model.

Numeric size

Exactness does not promise unlimited computation. Operand sizes, intermediate products, rational reduction, division, comparison, and encoding all require bounded work. The resource contract governs logical allocation and reservations.

Host integer width is not a numeric rule. A product must either support an admitted exact calculation under its fixed semantic limits or report the specified failure. It cannot wrap a value, saturate it, or substitute a rounded approximation.

4.11 Bound numeric work without changing its meaning

Exact numeric operations apply work limits, logical allocation, and the terminal-failure rule. Numeric growth and intermediate values contribute their declared events. A failed numeric operation returns no wrapped, truncated, or rounded result. Host word size cannot change an admitted calculation.

Why

Exact arithmetic can grow beyond the size of its source literals. Charging that growth preserves finite execution while keeping numeric meaning independent of machine word width.

Calculate beyond a 64-bit unsigned range

lispex.example.v2.numbers.beyond-machine-word · 1판

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (+ 18446744073709551615 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": "list",
        "items": []
      }
    }
  ],
  "rootModule": "main",
  "moduleSources": [
    {
      "name": "main",
      "source": "source.scm"
    }
  ]
}
명세상 결과
결과18446744073709551616
결과 상세
{
  "kind": "value",
  "valueCount": 1,
  "datum": {
    "kind": "integer",
    "value": "18446744073709551616"
  }
}

명세상 결과입니다. 2.0 어댑터가 준비되면 제품에서 실행합니다.

제품 실행

예상 결과

With sufficient finite limits, the result is the exact integer 18446744073709551616. Product invocation awaits its 2.0 adapter.

The operand is a test value, not a language limit. A machine word boundary cannot change the sum or select a different failure on an admitted product.

Stop an unending calculation with numeric growth

lispex.example.v2.numbers.growing-exact-calculation · 2판

source.scm
(module main
  (import)
  (export rule)
  (entry rule)
  (define rule
    (lambda (input)
      (let loop ((number 2))
        (loop (* number number)))))
)
요청과 파일
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": "fixed finite work and logical allocation values"
  },
  "requests": [
    {
      "input": {
        "kind": "list",
        "items": []
      }
    }
  ],
  "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 어댑터가 준비되면 제품에서 실행합니다.

의미 상세
{
  "returnedControl": true,
  "approximationFallback": false,
  "partialResult": false
}
제품 실행

예상 결과

The finite resource contract stops the growing calculation and returns control. No partial value or approximate substitute is returned. Product invocation awaits its 2.0 adapter.

The square grows on every iteration. The final resource model determines the first exhausted axis and site for each fixed set of finite limits. Those details require the model to be frozen and do not imply a product pass.

Related chapters

Source and normalization

Values and text

Resources

Standard library