API

セレクタの一覧はコンパイラが持つ型シグネチャの表から生成しています。この表に無いセレクタはコンパイルエラーになります。完全な一覧は配布物に同梱の lpsc api の出力にあります。このページは主なものの概要です。

数値

型主なセレクタ
Int+ - * // \\ < abs max: min: between:and: asDecimal asFloat asString to: to:collect: timesRepeat:
FloatInt と同じ算術。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: indexOf:from: asUppercase asLowercase reversed trimmed asInteger asDecimal asDate asTime asDateTime asSymbol collect: do:
Charvalue code
Symbolname
Booland: or: not ifTrue:ifFalse:

asInteger asDecimal asDate asTime asDateTime は Maybe を返します。変換できない文字列は none です。'1,000' は none になります。

人が入力した文字列には asEnteredInteger asEnteredDecimal asEnteredDate asEnteredTime asEnteredDateTime を使います。全角数字、桁区切りのコンマ、斜線区切りの日付、9:05 のような時刻を正規化してから読みます。12x は none、2026/2/30 も 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: distinct sum 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: で順序を指定します。sum は要素が Int または Decimal のときだけ使えます。空配列の sum が 0 か 0.00 かを決めるために、要素の型が確定している必要があります。

日付と時刻

型主なセレクタ
Dateyear month day dayOfWeek dayOfYear plusDays: minusDays: plusMonths: plusYears: startOfMonth endOfMonth daysUntil: isLeapYear slashed と比較。生成: Date today Date year:month:day:
Timehour minute second secondsFromMidnight と比較。生成: Time hour:minute: Time fromSeconds:
DateTimedate time と比較。生成: DateTime date:time:
Instant比較、millis plusSeconds: plusMillis: millisUntil:、localDate localTime localDateTime、dateAtOffset: dateTimeAtOffset:。現在時刻: Instant now

Date は時刻もタイムゾーンも持ちません。plusMonths: は暦に従い、31 日の一か月後は翌月の末日です。

Time どうしの加算はできません。秒に変換して計算し、Time fromSeconds: で戻します。範囲外はエラーです。

DateTime は絶対時刻ではありません。Instant との変換にはタイムゾーンを指定します。localDate などは実行環境のタイムゾーン、dateAtOffset: 540 は分単位のオフセットです。タイムゾーンのデータベースは持たないので、DateTime から Instant への変換はありません。

経過時間は Instant now millis の差で測ります。

JSON と HTTP

型主なセレクタ
Jsonat: at:put: itemAt: keys size isNull asStr asInt asDecimal asFloat asBool asArray asText
Json(クラス側)parse: object: array: str: int: decimal: bool: null
Httpget: get:headers: post:json: post:json:headers: post:text: post:bytes:type: post:file:named:type: put:json: delete: url:query: encode: deadline:
Responsestatus body bytes json ok reason header:

at: は例外を投げません。オブジェクトでない値に送ると null の Json を返します。asInt などの型変換は Maybe を返します。

Http の要求は例外を投げません。接続できない場合は status 0 の Response を返し、reason に理由が入ります。

at:put: は指定したキーだけを差し替え、他のキーは保持します。画面が扱わない項目を含む JSON を、そのままサーバへ返せます。

ファイル

型主なセレクタ
Bytessize asText asTextIn: asCodes。生成: Bytes empty Bytes ofText: Bytes ofCodes:
Base64encode: decode: encodeUrl: decodeUrl:

ファイルはイベントで受け取ります。on: #change sendFileText: #loaded:text: と書くと、ファイルの読み込みが始まり、名前と内容が揃ったときにハンドラへ届きます。文字列として読まないファイルには sendFileBytes: を使います。ファイル選択、貼り付け(#paste)、ドラッグ&ドロップ(#drop)は同じハンドラで受け取れます。

ファイルを渡すには App save: 'orders.csv' type: 'text/csv' text: s または save:type:bytes: を使います。

asText は UTF-8 として読みます。他の文字コードは asTextIn: 'ISO-2022-JP' のように名前で指定します。読める文字コードはブラウザと Node の TextDecoder に依存します(ISO-2022-JP、Shift_JIS、EUC-JP は両方で使えます)。Base64 decode: と asTextIn: は Maybe を返します。外部から来る文字列で例外を出さないためです。

Bytes ofCodes: と asCodes で、整数の配列とバイト列を相互に変換できます。base64 以外のエンコード方式(quoted-printable など)のデコーダは、これを使って LPScript で書けます。0 から 255 の範囲外の値はエラーです。UTF-8 以外の文字コードへの変換はありません。ブラウザの TextEncoder が UTF-8 しか出力しないためです。

Bytes は Worker へ渡せます。

画面

型主なセレクタ
Htmlclone: clone:fill: el: el:text: el:attrs: el:kids: el:attrs:kids: text: markup: child: child:as: all:
VNodeat:put: at:kids: at:class: at:attr:is: on:send: on:send:with: on:sendValue: on:sendEvent: on:sendFileText: on:sendFileBytes: at:on:send: key: class: addClass: removeClass: at:addClass: at:removeClass: attr:is: preventDefault preventDefaultOn: preventDefaultOn:keys: preventDefaultAt:on: stopPropagation stopPropagationOn:
Eventkind value checked key x y scrollTop height shift ctrl alt meta
Appmount: mount:at: page: path go: replace: save:type:text: save:type:bytes: html: htmlAt:

App にはテスト用のセレクタもあります。click: type:text: press:key: check:is: focus: blur scrollTo: selectAll: です。

on: で始まるセレクタに渡すのはハンドラ名です。ハンドラ名はコンパイル時に検査され、存在しないハンドラはコンパイルエラーになります。イベントが運ぶ値にも型が付きます。共通部品がハンドラ名を受け取って送信する場合も同様に検査されます。

at: '.cred' class: 'sec off' は .cred で選んだノードの class を sec off に置き換えます。置き換え後は .cred で探せなくなります。addClass: と removeClass: は class を一つだけ追加または削除し、他の class は保持します。

preventDefaultOn: #drop は指定したイベントの既定動作だけを止めます。同じノードの #paste には影響しません。preventDefaultOn: #keydown keys: #('ArrowUp' 'ArrowDown' 'Enter' 'Escape') は指定したキーの既定動作だけを止め、他のキーの入力は通します。この指定は状態に応じて変えられます。

checked disabled readonly required selected の属性値は真偽として解釈します。'' 'false' '0' 'no' 'off' は偽で属性を付けず、それ以外は真です。

アクタ

型主なセレクタ
Actor(クラス側)spawn: spawn:named: spawn:as:
ActorRef[c]tell ask name stop isAlive as:
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: ほか
Downactor reason
Future[a]forced then: onError:
Future(クラス側)value: all: after:do: sleep:
Worker(クラス側)new spawn:on:

spawn:as: は生成時に参照をプロトコルの型にします。as: は既存の参照をプロトコルの型にします。親が自分の参照を子に渡すときは me ref as: Owner と書きます。クラスがそのプロトコルを実装していなければコンパイルエラーです。become: で置き換わる先のクラスも、そのプロトコルを実装している必要があります。

ActorRef[a] としか型の付いていない参照への tell と ask はコンパイルエラーです。照合するハンドラが無いためです。

isAlive は Maybe[Bool] を返します。同じスレッドのアクタは生死が分かります。別スレッドのアクタは分からないので none です。別スレッドのアクタの生死は monitor: で通知を受けます。

その他

Console(printLine:)、Math、Sys、Error(signal:)があります。

クラスは fieldNames で項目名の一覧を返します。値は fieldAt: と fieldAt:put: で項目を名前で読み書きできます。値の受け渡しは Json です。プロトコルは implementors で、実装しているクラスの一覧を Dict で返します。キーはクラス名の先頭を小文字にしたものです。

一覧の検証

この表はコンパイラの型シグネチャの表から生成しています。表に無いセレクタはコンパイルエラーです。表にあるセレクタがランタイムに実装されているかは、自動テストで照合しています。