API
The selector tables are generated from the compiler's type signature table. A selector that is not in the table is a compile error. The full list is the output of lpsc api, which ships with the distribution. This page is an overview.
Numbers
| Type | Main selectors |
|---|---|
Int | + - * // \\ < abs max: min: between:and: asDecimal asFloat asString to: to:collect: timesRepeat: |
Float | Same arithmetic as Int, plus sqrt floor ceiling rounded asInteger |
Decimal | + - * / and comparisons. Rounding: roundedTo: truncatedTo: floorTo: ceilingTo: awayFromZeroTo:. Divide and round: dividedBy:roundedTo: and others. Display: grouped groupedTo: |
Int is a BigInt. Decimal's / is an error when the result is not exact. Use dividedBy:...To: to divide with rounding.
Strings
| Type | Main selectors |
|---|---|
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: |
Char | value code |
Symbol | name |
Bool | and: or: not ifTrue:ifFalse: |
asInteger, asDecimal, asDate, asTime, and asDateTime return a Maybe. A string that does not parse is none. '1,000' is none.
For strings typed by a user, use asEnteredInteger, asEnteredDecimal, asEnteredDate, asEnteredTime, and asEnteredDateTime. They normalize full-width digits, thousands separators, slash-separated dates, and times like 9:05 before parsing. 12x is none, and 2026/2/30 is none.
Collections
| Type | Main selectors |
|---|---|
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 and Dict are immutable. at:put: returns a new Dict. sorted is available only when the elements support <; otherwise use sortBy:. sum is available only for Int and Decimal elements. The element type must be known so that the sum of an empty array is 0 or 0.00 as appropriate.
Dates and times
| Type | Main selectors |
|---|---|
Date | year month day dayOfWeek dayOfYear plusDays: minusDays: plusMonths: plusYears: startOfMonth endOfMonth daysUntil: isLeapYear slashed, and comparisons. Construction: Date today Date year:month:day: |
Time | hour minute second secondsFromMidnight, and comparisons. Construction: Time hour:minute: Time fromSeconds: |
DateTime | date time, and comparisons. Construction: DateTime date:time: |
Instant | Comparisons, millis plusSeconds: plusMillis: millisUntil:, localDate localTime localDateTime, dateAtOffset: dateTimeAtOffset:. Current time: Instant now |
Date has no time and no time zone. plusMonths: follows the calendar: one month after the 31st is the last day of the next month.
Time values cannot be added. Convert to seconds, compute, and convert back with Time fromSeconds:. Out-of-range values are an error.
DateTime is not an absolute time. Converting to or from Instant requires a time zone. localDate and similar use the host's time zone; dateAtOffset: 540 takes an offset in minutes. There is no time zone database, so there is no conversion from DateTime to Instant.
Measure elapsed time as the difference of two Instant now millis values.
JSON and HTTP
| Type | Main selectors |
|---|---|
Json | at: at:put: itemAt: keys size isNull asStr asInt asDecimal asFloat asBool asArray asText |
Json (class side) | parse: object: array: str: int: decimal: bool: null |
Http | get: get:headers: post:json: post:json:headers: post:text: post:bytes:type: post:file:named:type: put:json: delete: url:query: encode: deadline: |
Response | status body bytes json ok reason header: |
at: does not throw. Sent to a value that is not an object, it returns the null Json. Conversions such as asInt return a Maybe.
Http requests do not throw. A failed connection returns a Response with status 0, and reason describes the failure.
at:put: replaces one key and keeps the others. A JSON document can be returned to the server with fields the screen never modelled still in it.
Files
| Type | Main selectors |
|---|---|
Bytes | size asText asTextIn: asCodes. Construction: Bytes empty Bytes ofText: Bytes ofCodes: |
Base64 | encode: decode: encodeUrl: decodeUrl: |
Files are received through events. on: #change sendFileText: #loaded:text: starts reading the file and delivers the name and contents to the handler when reading finishes. Use sendFileBytes: for files that must not be decoded as text. File selection, paste (#paste), and drag-and-drop (#drop) can use the same handler.
To hand a file to the user, use App save: 'orders.csv' type: 'text/csv' text: s or save:type:bytes:.
asText decodes as UTF-8. Other encodings are specified by name, as in asTextIn: 'ISO-2022-JP'. Which encodings are available depends on the browser's or Node's TextDecoder (ISO-2022-JP, Shift_JIS, and EUC-JP are available in both). Base64 decode: and asTextIn: return a Maybe so that malformed external input does not raise.
Bytes ofCodes: and asCodes convert between an array of integers and a byte array. Decoders for other encodings, such as quoted-printable, can be written in LPScript with these. Values outside 0–255 are an error. There is no encoding to anything other than UTF-8, because the browser's TextEncoder produces only UTF-8.
Bytes can be passed to a Worker.
Views
| Type | Main selectors |
|---|---|
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: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: |
Event | kind value checked key x y scrollTop height shift ctrl alt meta |
App | mount: mount:at: page: path go: replace: save:type:text: save:type:bytes: html: htmlAt: |
App also has selectors for testing: click: type:text: press:key: check:is: focus: blur scrollTo: selectAll:.
The on: selectors take a handler name. Handler names are checked at compile time; an unknown name is a compile error. The value an event carries is typed. This applies also when a shared component receives a handler name and performs the send.
at: '.cred' class: 'sec off' replaces the class list of the node selected by .cred with sec off, after which .cred no longer matches it. addClass: and removeClass: add or remove one class and keep the rest.
preventDefaultOn: #drop cancels the default action of one event only; #paste on the same node is unaffected. preventDefaultOn: #keydown keys: #('ArrowUp' 'ArrowDown' 'Enter' 'Escape') cancels the default action for the named keys only. The declaration can change with the state.
The attributes checked, disabled, readonly, required, and selected are interpreted as booleans. '', 'false', '0', 'no', and 'off' are false and remove the attribute; anything else is true.
Actors
| Type | Main selectors |
|---|---|
Actor (class side) | 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: and others |
Down | actor reason |
Future[a] | forced then: onError: |
Future (class side) | value: all: after:do: sleep: |
Worker (class side) | new spawn:on: |
spawn:as: types a reference by a protocol when the actor is created. as: types an existing reference by a protocol. A parent passes itself to a child with me ref as: Owner. The class must implement the protocol, and any class it becomes with become: must implement it too.
tell and ask on a reference typed only as ActorRef[a] are compile errors, because there is no handler to check against.
isAlive returns a Maybe[Bool]. For an actor on the same thread, the result is known. For an actor on another thread it is none. Use monitor: to be notified when an actor on another thread stops.
Other
Console (printLine:), Math, Sys, and Error (signal:).
A class answers fieldNames. A value answers fieldAt: and fieldAt:put:, which read and write a field by name. Values are passed as Json. A protocol answers implementors, a Dict of the classes that implement it, keyed by class name with the first letter in lowercase.
Verification
The tables are generated from the compiler's type signature table. A selector not in the table is a compile error. An automated test checks that every selector in the table is implemented in the runtime.