Lowent 매뉴얼←↑→

부록 A — 낱말과 내장 연산

낱말을 설명하는 곳은 본문이다. 이 부록은 코드를 읽다 막혔을 때 훑어볼 표만 모은다. 낱말 목록은 명세의 부록 A 와 같고, 그 목록에 없는 것은 낱말이 아니다.

낱말 마흔셋#

갈래낱말다루는 장
선언module use type newtype struct enum trait contract actor state21·13장
opfn proc export unsafe extern satisfies5장
지역let var set be6장
흐름if else while for guard match case return break continue try7장
식과 값expr make true false none8장
동시성spawn send25장
소유drop19장
시험test expect31장
블록do end3장

표 50.1 — 낱말의 전부

rem 과 note 는 주석을 여는 표시이고, input·output·effects·requires 같은 절 머리와 add·len 같은 내장 연산은 낱말이 아니지만 이름으로 쓸 수 없다.

없앤 낱말#

없앤 것대신
loopwhile true .
givereturn
unitvoid
calcop · procopfn · proc
is · as(선언 속) · local적지 않는다
to · in(칸 접근)field a b · index a i
on액터 안의 proc
failreturn error <갈래>
; · ,.

표 50.2 — 없앤 낱말과 대신 쓰는 것(E-VOCAB-REMOVED)

as 와 to 는 use … as <별칭> 과 case <아래> to <위> 의 자리 표식으로만 남아 있다.

자주 쓰는 내장 연산#

갈래연산
산술(멈춤)add sub mul div mod neg abs min max
산술(처분을 고름)wrap_* sat_* chk_* div_nz nonzero_of
폭 바꾸기widen narrow narrow_wrap narrow_sat narrow_try cast bit_cast
비교와 논리eq ne lt le gt ge and or not
비트bit_and bit_or bit_xor bit_not shl shr rotl rotr wrap_shl wrap_shr count_ones leading_zeros trailing_zeros byte_swap clmul_lo clmul_hi
줄len index subslice view view_array same_slice
묶음field method isa get
답을 담는 타입some ok error is_some is_none is_ok is_error some_value ok_value error_value value_or
번역 시점size_of comptime config
할당alloc_bytes
입출력 잎write_out read_in arg · 파일·연결·시계·난수·터미널 잎은 표준 라이브러리가 감싼다
원자atomic_load atomic_store atomic_add atomic_sub atomic_swap atomic_cas atomic_fence
장치read_volatile write_volatile
동시성await drain channel chsend chrecv yield spawn send
원자(비트)atomic_and atomic_or atomic_xor
부동소수 수학 — 4장sqrt sin cos exp log pow floor ceil round fmod sum_neumaier sum_seq
파이프 단계 — 24장pipe map filter fold scan take skip zip enumerate reverse collect count all any into
레인(SIMD) — 27장splat load store load_masked store_masked select reduce_add reduce_mul reduce_min reduce_max avg native_lanes rotate prefetch
작은 수의 집합 — 13장bitset_new union intersect difference complement contains is_subset is_empty remove
배치와 뷰 — 13장encode try_view view_segments seg segs capacity
빌림과 영역 — 12장 · 18장ref mut_ref deref borrow region stack_new push pop swap
계약과 오류 — 14장range ret expect panic
계산 잎 — call_builtin 뒤에서만 선다clmul_lo clmul_hi aes_round aes_round_last aes_ctr ghash chacha20 poly1305 aes_gcm chacha_poly sha256 sha384 sha512 crc32 hash_bytes rng_next
C 문자열 — 29장cstr_of str_from_cstr
호스트 잎 — 32장file_open file_read file_write file_seek file_close file_type link_type dir_open dir_read dir_close dir_make path_remove path_rename net_listen net_accept net_connect net_resolve net_send net_recv net_close net_pair net_port env_get reactor_new r_read r_write

표 50.3 — 내장 연산의 갈래

★ 계산 잎 열다섯은 전역 어휘가 아니다. call_builtin sha256 msg out 처럼 그 자리에서만 선다 — 맨몸으로 부르면 E-BUILTIN-BARE, 모르는 이름을 대면 E-BUILTIN-NAME 이다. 까닭은 하나다: 프로그램이 한 번 쓰는 낱말로 전역 어휘가 늘면 읽는 사람이 외울 것이 는다. 같은 규율이 pipe 안의 단계 이름과 cast u8 x 의 타입 자리에도 이미 있다.

이 표는 정본의 내장 연산을 빠짐없이 무리로 나눈 것이다. 무리 이름 옆의 장이 그 무리를 예제와 함께 설명한다. 한 줄씩의 뜻은 저장소의 docs/spec/BUILTIN-MEANINGS.tsv 가 정본이다.

효과와 권한#

효과허락하는 권한다루는 장
iocap io · file_system · net · tty · clock · random16장
alloc · heapcap allocator · cap heap18·20장
atomiccap atomic27장
devicecap mmio30장
unsafecap c · cap machine(쓰는 자리에 따라)29·30장
state · panic · wait · concurrent권한 없이 적는다15·26장

표 50.4 — 효과 원자와 짝이 되는 권한