aboutsummaryrefslogtreecommitdiffstats
path: root/docs/design/016-bool-and-i64.md
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-09-30 15:24:56 +0100
committereunhhu <[email protected]>2026-09-30 15:24:56 +0100
commitbfa54e02881f56b3a969220ecaac706542046149 (patch)
tree8c1e1b6d5a4b8a222cc56a6dc8e6a08a52a7a508 /docs/design/016-bool-and-i64.md
parent16fab9f3d71fa1fdb4cd38f7e9ae1e1eb4e75340 (diff)
downloadpure-bfa54e02881f56b3a969220ecaac706542046149.tar.gz
pure-bfa54e02881f56b3a969220ecaac706542046149.zip
Give bools their own type in the module format (v6, 016 stage 1)
A condition was a number, non-zero being true: a flag was a number field, a view showed 1 for true, and nothing kept a number from standing for a bool or a bool from being added to. Now the verifier has a bool among its stack types, and a verified module never mixes the two. No opcode is new: - CONST with argument 1 is a bool (+0 or 1), NUM_TEXT with argument 1 writes one as true or false; LOAD and STORE take a number or a bool state, locals may hold a bool (2). - Comparisons (LT to NE, TEXT_COMPARE) and LIST_HAS give a bool; AND, OR and NOT take and give them; JZ, REQUIRE, filters and folds' tests take one (count and first leave a bool, sum, max, min and distinct a number and a bool); EQ and NE compare two bools too. - Type codes: state 5, record field 2, message field 6 (one byte in the prefix, 0 or 1, or the message fails as limit), view 3. A bool's constant, initial value and default are +0 or 1; a list is not keyed by one. PUREMOD6: v5 modules are built again. At run time a bool is a number's 0 or 1, so leaf-at-a-time folds run as before. A number that becomes a bool (a module replaced, a stored state or item read again, a waiting send recast) keeps 0 (either sign) and 1 and takes the default otherwise; a bool that becomes a number is 0 or 1. The host carries bools on every boundary: JSON true and false only (a row's field too), a query's true and false, true and false in views, table JSON and HTTP deliveries; a link takes a bool only into a bool. A stored outbox's field types were read back with a check that refused bool (at or past rows): a node whose output had a bool field and a send waiting could not start again. test-module now stores such a send and opens it (it fails on the old check), beside 28 bool refusals of the verifier and bool states, fields, views, sends, links and migration. The lane generator makes numbers and bools apart.
Diffstat (limited to 'docs/design/016-bool-and-i64.md')
-rw-r--r--docs/design/016-bool-and-i64.md14
1 files changed, 8 insertions, 6 deletions
diff --git a/docs/design/016-bool-and-i64.md b/docs/design/016-bool-and-i64.md
index dc438a0..ead3ae8 100644
--- a/docs/design/016-bool-and-i64.md
+++ b/docs/design/016-bool-and-i64.md
@@ -32,11 +32,13 @@ aup의 원칙(002)을 따른다. 위치가 정수가 아니듯 참·거짓은 �
**모듈 형식 v6(Pure).** 판을 올린다. 비교의 결과 종류가 바뀌므로 v5 모듈은 다시 빌드한다.
- 검증기의 스택 종류에 bool을 더한다. 실행 중의 값은 수 칸의 0과 1이다.
-- bool을 내는 명령: LT–NE, TEXT_COMPARE, LIST_HAS, AND·OR·NOT, 새 명령 BOOL_CONST(값 0이나 1).
-- bool을 받는 명령: JZ, REQUIRE, AND·OR·NOT, 집계의 포함 여부(count와 first는 bool 하나, sum·max·min은 수와 bool),
- 걸러진 표의 필터, 새 명령 BOOL_TEXT(bool → text, `true`·`false`).
+- 새 명령은 없다. CONST의 인자 1이 bool 상수(값 +0이나 1)이고, NUM_TEXT의 인자 1이 bool을 `true`·`false`로 쓴다.
+ LOAD·STORE와 지역 칸은 수와 bool을 함께 다룬다(상태의 타입이나 칸의 담는 것이 정한다).
+- bool을 내는 명령: LT–NE, TEXT_COMPARE, LIST_HAS, AND·OR·NOT. EQ와 NE는 bool 둘도 비교한다.
+- bool을 받는 명령: JZ, REQUIRE, AND·OR·NOT, 집계의 포함 여부(count와 first는 bool 하나, sum·max·min·distinct는 수와
+ bool), 걸러진 표의 필터.
- 새 타입 번호: 상태 5(bool, 8 B 값은 f64 0이나 1), 레코드 필드 2(bool, 기본값 f64 0이나 1), 메시지 필드 6(bool, 접두부의
- 1바이트 0이나 1), 보기 3(bool). 지역 칸의 담는 것 2(bool).
+ 1바이트 0이나 1), 보기 3(bool). 지역 칸의 담는 것 2(bool). 상수, 초기값, 기본값은 +0이나 1이어야 한다.
- 메시지의 bool 필드 바이트가 0이나 1이 아니면 메시지가 `limit`으로 실패한다(도착할 때, 015의 거절과 같은 자리).
**경계(015에 더한다).**
@@ -45,8 +47,8 @@ aup의 원칙(002)을 따른다. 위치가 정수가 아니듯 참·거짓은 �
- 쿼리: `true`·`false`.
- 저장: 목록의 bool 필드는 수 열의 0과 1이다(저장 형식도 수다). 레코드의 필드 타입이 뜻을 정한다.
- 전달: 링크의 FIELDS와 HTTP 전달의 JSON이 bool을 bool로 싣는다. 받는 입력의 필드도 bool이어야 한다. 넓히기는 없다.
-- 모듈 교체: 수 필드나 상태가 bool이 되면 0과 1은 `false`와 `true`로 옮기고, 다른 수는 기본값이 된다. bool이 수가 되면
- `false`와 `true`는 0과 1이다.
+- 모듈 교체: 수 필드나 상태가 bool이 되면 0(−0도, 015)과 1은 `false`와 `true`로 옮기고, 다른 수는 기본값이 된다. bool이
+ 수가 되면 `false`와 `true`는 0과 1이다. 저장소에서 다시 열 때와, 교체가 출력의 필드를 바꿀 때 기다리던 보냄도 같다.
- 화면(Vega): 글자로는 `true`·`false`다(보간과 같다). 앱이 다르게 보이고 싶으면 조건식으로 글을 고른다.
**옮기는 비용.** 예제의 수 깃발을 bool로 바꾼다(`done`, `urgent`, `running`, `holding`). 저장된 0과 1은 위의 교체 규칙으로