aboutsummaryrefslogtreecommitdiffstats
path: root/docs/design/002-dsl-direction.md
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-10-04 11:50:55 +0100
committereunhhu <[email protected]>2026-10-04 11:50:55 +0100
commitda7e2c63117d58684d45eb0adde36243f96342f6 (patch)
tree7033bffbfc85b419eaa1002db9053c4e20aca723 /docs/design/002-dsl-direction.md
parentcb1202003373b344cefeecb584139fafadb273b4 (diff)
downloadaup-da7e2c63117d58684d45eb0adde36243f96342f6.tar.gz
aup-da7e2c63117d58684d45eb0adde36243f96342f6.zip
Say what library records showed (002)
The task list's module is the same with its record in a library (2,509 bytes); one record of a library's three goes into a module using one; a migration of the same library moves what the app stored; eleven diagnostics. The example compiles.
Diffstat (limited to 'docs/design/002-dsl-direction.md')
-rw-r--r--docs/design/002-dsl-direction.md18
1 files changed, 15 insertions, 3 deletions
diff --git a/docs/design/002-dsl-direction.md b/docs/design/002-dsl-direction.md
index 921a9e8..2cbe914 100644
--- a/docs/design/002-dsl-direction.md
+++ b/docs/design/002-dsl-direction.md
@@ -237,7 +237,7 @@ view summary = words.counted(tasks.count, "task", "tasks")
인자를 여러 번 써도 다시 계산하지 않으며, 쓰지 않는 인자도 계산한다(값 전달). 재귀는 컴파일 오류다.
그래서 실행량 상한과 로드 전 검증이 그대로 유지된다.
- **use는 라이브러리를 가져온다.** `use words`는 소스 옆의 `words.aup`, 없으면 `AUP_PATH`(`:`로 구분)의 디렉터리에서
- 찾는다. 라이브러리는 `fn`과 `use`만 선언하고 앱의 상태를 볼 수 없다(매개변수만 읽는다). 부를 때는
+ 찾는다. 라이브러리는 `fn`, `record`(아래), `use`만 선언하고 앱의 상태를 볼 수 없다(매개변수만 읽는다). 부를 때는
`words.counted(...)`처럼 라이브러리 이름을 붙인다. 순환 use는 오류이고, 라이브러리의 오류는 그 파일 경로로 알린다.
- Vega는 이 자리에 들어간다. 인터페이스 어휘를 fn과 표 보기 위의 규약으로 제공하는 aup 라이브러리다.
@@ -246,7 +246,7 @@ view summary = words.counted(tasks.count, "task", "tasks")
검증: 라이브러리를 쓴 할 일 목록이 참조 모델과 일치하고, 인자를 한 번만 계산하며(값 전달), 라이브러리 경로·순환·
상태 선언·앱 상태 읽기 오류가 해당 파일 위치로 보고된다. 같은 소스와 라이브러리는 같은 모듈을 만든다. 진단 10건을 더했다.
-### 라이브러리의 레코드 (설계)
+### 라이브러리의 레코드 (구현)
[외부 리뷰 005](/srv/git/pure.git)의 (4)에서 시작한다. 라이브러리는 `fn`과 `use`만 선언할 수 있어서, 레코드는 앱의 파일
하나에 모여야 했다. 같은 저장소를 읽는 두 번째 모듈(옮기기 스크립트, 질의)은 레코드를 베껴 써야 했다. 상태는 앱 하나의
@@ -262,7 +262,7 @@ use store
state users: list of store.User by name
input join = message { name: text }
on join { users.add(store.User { name: join.name }) }
-view first = store.rank(users[join.name].points)
+view golds = count(u in users where store.rank(u.points) == "gold")
```
- **라이브러리는 `record`도 선언한다.** 여전히 상태, 입력, 보기, 핸들러, 출력은 선언하지 않는다.
@@ -288,6 +288,18 @@ view first = store.rank(users[join.name].points)
상태 이름이 겹침, 다른 레코드의 값을 리스트에 넣기, 라이브러리의 상태 선언(지금처럼 오류).
- aup, Pure, Vega의 검사가 모두 초록이다.
+검증(`tests/check.py`의 `library_records`): 레코드를 라이브러리로 옮긴 할 일 앱이 옮기기 전과 같은 모듈(2,509바이트)을
+만든다. 레코드 셋을 가진 라이브러리에서 하나를 쓰는 앱의 모듈에는 레코드가 하나다. 앱이 `pure-run --store`로 사용자 셋을
+넣고, 같은 라이브러리를 쓰는 옮기기 모듈이 같은 저장소에서 사용자마다 점수 10을 더하고, 앱이 다시 열어 30을 본다. 메시지의 행
+필드가 라이브러리의 레코드를 받는다. 위의 진단 여섯과 함께 같은 이름의 레코드가 두 라이브러리에서 올 때, 다른 레코드의 값,
+라이브러리 안의 이름 겹침 진단을 더했다(11건).
+
+- 레코드 이름을 모듈에서 앞에 붙이지 않는 까닭은 Pure다. 모듈의 레코드 이름은 점이 없는 식별자이고 상태와 한 이름공간이다.
+ `store.User`를 `store_User` 같은 이름으로 바꿔 넣으면 레코드를 옮길 때 모듈이 바뀌고, 같은 저장소를 읽는 질의(이름까지 같아야
+ 한다, Pure `same_states`)가 앱과 맞지 않게 된다.
+- 값을 이름이 아니라 선언으로 맞추는 까닭: 쓰이지 않아 모듈에 없는 다른 라이브러리의 같은 이름 레코드가, 이름만 같아서 리스트에
+ 들어가는 일을 막는다.
+
### 시간
```text