API
型ごとのセレクタは、コンパイラが持っている一つの表から出しています。その表が、何が呼べるかを決める唯一の場所です。 全量は配布物に同梱の一覧(lpsc api が出力するもの)にあります。ここでは、どの型に何があるかを見渡せるようにします。
数と金額
| 型 | 主なセレクタ |
|---|---|
Int | + - * // \\ < abs max: min: between:and: asDecimal asFloat asString to: to:collect: timesRepeat: |
Float | Int と同じ算術。sqrt floor ceiling rounded asInteger |
Decimal | + - * / と比較。丸めは方向を名前で書く — roundedTo: truncatedTo: floorTo: ceilingTo: awayFromZeroTo:。割り算は dividedBy:roundedTo: の形で、どこまで残すかを一緒に書く。表示は grouped groupedTo: |
Int は BigInt です。桁は落ちません。Decimal の / は割り切れなければエラーになるので、割り切れない計算は dividedBy:...To: を使います。
文字と記号
| 型 | 主なセレクタ |
|---|---|
Str | , size at: copyFrom:to: splitOn: replaceAll:with: startsWith: endsWith: includesSubstring: indexOf: asUppercase asLowercase reversed trimmed asInteger asDecimal asDate asSymbol collect: do: |
Char | value |
Symbol | name |
Bool | and: or: not ifTrue:ifFalse: |
asInteger asDecimal asDate は Maybe を返します。読めない文字列は例外ではなく none です。
並びと対応
| 型 | 主なセレクタ |
|---|---|
Array[a] | size isEmpty first last at: at:ifAbsent: do: doWithIndex: collect: select: reject: detect:ifNone: inject:into: includes: indexOf: copyWith: take: drop: reversed sorted sortBy: joinWith: allSatisfy: anySatisfy: , |
Dict[k v] | at: at:ifAbsent: at:put: removeKey: includesKey: keys values size collect: select: do: |
Assoc[k v] | key value |
Maybe[a] | isPresent isAbsent value orElse: map: ifPresent: ifPresent:ifAbsent: |
Array も Dict も値です。at:put: は新しい Dict を返し、元は変わりません。sorted は要素が < を答える型のときだけ使えます。答えない型は sortBy: に順序を渡します。
日付と時刻
| 型 | 主なセレクタ |
|---|---|
Date | year month day dayOfWeek dayOfYear plusDays: minusDays: plusMonths: plusYears: startOfMonth endOfMonth daysUntil: isLeapYear slashed と比較 |
Instant | 比較、asString、Date への変換(時間帯を名指しする) |
Date に時刻も時間帯もありません。plusMonths: は暦のとおりで、31日の一か月後は翌月の末日になります。
JSON と HTTP
| 型 | 主なセレクタ |
|---|---|
Json | at: itemAt: keys size isNull asStr asInt asDecimal asFloat asBool asArray asText |
Json(クラス側) | parse: object: array: str: int: decimal: bool: null |
Http | get: get:headers: post:json: post:text: put:json: delete: url:query: encode: deadline: |
Response | status body ok header: |
at: は例外を投げません。オブジェクトでないものに送れば null の Json が返るので、途中を確かめずに辿れます。葉の asInt などが Maybe を返します。Http の要求は失敗しません。線が立たなければ status 0 の Response が返ります。
画面
| 型 | 主なセレクタ |
|---|---|
Html | clone: clone:fill: el: el:text: el:attrs: el:kids: el:attrs:kids: text: markup: child: child:as: all: |
VNode | at:put: at:kids: at:class: at:attr:is: on:send: on:sendValue: on:sendEvent: at:on:send: key: class: attr:is: preventDefault stopPropagation |
Event | kind value checked key x y scrollTop height shift ctrl alt meta |
App | mount: mount:at: page: path go: replace: html: htmlAt: |
App にはもう一組、検査のためのセレクタがあります。click: type:text: press:key: check:is: focus: blur scrollTo: です。画面を書くときには使いません。
アクタ
| 型 | 主なセレクタ |
|---|---|
Actor(クラス側) | spawn: spawn:named:、それに spawn:as:(参照をプロトコルで型付ける) |
ActorRef[c] | tell ask(送るのは宣言したハンドラ名)、name stop |
ActorCtx[c](me) | ref name spawn: spawn:as: monitor: demonitor: link: stop stop: after:send: onPath: listen:on:send: listen:on:sendValue: listen:on:sendEvent: intercept:on:send: ほか |
Down | actor reason |
Future[a] | forced then: onError: |
Future(クラス側) | value: all: after:do: sleep: |
Worker(クラス側) | new spawn:on: |
その他
Console(printLine:)、Math、Time、Sys、Error(signal:)があります。
一覧の出どころ
この頁の表は、コンパイラの中の署名表から出しています。そこに無いセレクタは、コンパイラが受け付けません。 実在するかどうかの検査も自動で走ります。コンパイラが「ある」と言っているセレクタが、ランタイム側に本当にあるかを機械が突き合わせています。