Expand description
The words of the program’s environment, imported from the “host” module and called like C functions:
sleep_ms(ms) pauses, random() is a float in [0, 1), random_below(n) an int in 0..n, clock() the milliseconds
since the Unix epoch. A program that defines a word of the same name keeps its own. warp adds the words that need
its compiler, the network or threads (host.rs); these need nothing.
signal_poll() and signal_listen(kind, id, argument) serve the handlers of system signals (system_signals.rs).
Constants§
- BASIC_
HOST_ WORDS - The words link_host_words provides
- BATTERY
- CHARGING
- CLICK_
PRESSED - Whether a click over the paint window is left to read (1, then it is the click read) or none (0), each click read
once, and that click’s place: natively
on click {…}(lowering/signals/system_signals.rs); not values a program names - CLICK_X
- CLICK_Y
- CLIPBOARD
clipboard: the clipboard’s text, read only when the program reads it (host.rs clipboard_text)- CLIPBOARD_
COUNT - How often the clipboard changed since the machine started (macOS NSPasteboard changeCount):
on clipboard change - CLIPBOARD_
TEXT - CLOCK
- CLOCK_
WEEKDAYS - The clock argument’s weekdays count in ten-thousands:
(signal_listen 2 0 1271290)is 21:30 (1290) every day (127) - DARK_
MODE - DISPLAY_
DPI - display.dpi: the screen’s device pixels per inch, which turn
pxinto lengths (decision dimensions-units) - DISPLAY_
HEIGHT - DISPLAY_
WIDTH - ESCAPE_
KEPT - Read once as a program naming the Escape key starts (
key == ESC): Escape over the paint window is then its key, else it ends the run (card escape-window, src/graphics/paint_window.rs); not a value a program names - EXIT
exit(code)ends the run, not the process (P121, system_signals.rs ExitRequest)- EXIT_
HANDLER - The exported handler of
on exit {…}, run once as the run ends (system_signals.rs run_exit_handler) - FETCH_
HANDLER_ PREFIX on·fetch·0: the handler run when the reply of the firstusers := fetch urlarrived (src/web/fetches.rs)- FILE_
HANDLER_ PREFIX on·file·0: the handler of the firston file "x" change {…}- FOREIGN_
CALL - foreign_call(runtime, module, member, call, arguments): a module of another runtime (foreign.rs), Nodes in and out
- GPU_
COMPUTE gpu_compute(shader, numbers, workgroups): a WGSL compute shader run over the numbers on the GPU (WebGPU in the browser, web/playground/host-gpu.js), the numbers it left (card web-apis, notes/web_framework.md “web-apis: WebGPU”)- GPU_
COMPUTE_ LINEAR gpu_compute(shader, xs, workgroups)of alinear xs = float[n]: the shader runs over the cells of the block in linear memory, read and written in place without building a list (card gpu-vectors, notes/gpu.md); gives the block back- GPU_
DRAWING - Whether
use drawdraws on the GPU (src/graphics/gpu_canvas.rs): natively in a window, or as WARP_DRAW says; never on a page - GPU_
MAP_ LINEAR ys = xs.map(x => …) @gpuof a linear float array (src/lowering/foreign/gpu_maps.rs): the WGSL kernel run over xs’s cells, written into ys’s; gives 1, or 0 without an adapter (said once), when the CPU maps them instead- GPU_
PAINTS - Whether a shader can paint here (1) or not (0):
paint(f, w, h)of a warp function reads it before painting f’s fragment shader, else paints f on the CPU (card paint-function, src/lowering/foreign/gpu_maps/kernels.rs); not a value a program names - GPU_
REDUCE_ LINEAR s = sum(xs.map(x => …) @gpu), min, max (src/lowering/foreign/gpu_maps.rs): the kernel leaves one partial result per workgroup, written into a block the program combines; 1, or 0 without an adapter, as gpu_map_linear- GPU_
RENDER gpu_render(shader, width, height): a WGSL fragment shadermainrun over every pixel, the pixels paint shows (0xFFRRGGBB row by row; card g_YqWY, notes/web_framework.md “web-apis: WebGPU”)- HANDLER_
PREFIX - What every exported handler name starts with
- HELD_
KEY - The name of the key held now (“a”, “ArrowUp”, “” for none), as
on keynames presses (card held-key): the word a program reads, made from KEY_CODE_HELD, the held key’s code (0: none), which it does not name - HOST_
LIBRARY - INTERRUPT_
HANDLER - The exported handler of
on interrupt {…}(src/lowering/signals/event_signals.rs) - KEY_
CODE_ HELD - KEY_
DOWN - Whether a key is held now, over the paint window or the page (card keyboard-state):
on keyhears each press - KEY_
HELD key_held(code): whether that key is held now, among others (card allow-diagonals:held_key == LEFTwhile UP is held too); code 0 whether none is- KEY_
PRESSED - The next key pressed over the paint window, its code (0: none left), each press read once: natively
on key {…}(lowering/signals/system_signals.rs); not a value a program names - LISTEN_
CLOCK - LISTEN_
EVERY - LISTEN_
FRAME - LOCAL_
OFFSET local_offset(ms): seconds east of UTC in the environment’s time zone (TZ) at that instant: an instant’s wall clock- MOUSE_
DOWN - MOUSE_
WHEEL - The wheel turned over the paint window or the page’s canvas since the start, in steps (notches): up (away from you) adds, down takes away; a trackpad’s scroll counts PIXELS_PER_WHEEL_STEP pixels a step (card shader-wheel)
- MOUSE_X
- The pointer over the page’s canvas, in canvas pixels, and whether a button is down (card drawing-frames)
- MOUSE_Y
- NOTIFY
notify "text": a desktop notification (system_values.rs notify; the playground: the browser’s Notification)- ONLINE
- PAGE_
PATH - The path of the page shown (“/users/7”), which picks its route (lowering/web/routes.rs); “/” natively
- PIXELS_
PER_ WHEEL_ STEP - RANDOM
- RANDOM_
BELOW - RANDOM_
SEED random_seed(n): random and random_below give the same numbers after the same seed (natively and in the browser)- SET_
SYSTEM_ VALUE set_system_value(name, value): writes one,window.width = 800resizes the paint window (system_values.rs write)- SHARED_
HANDLER - The checks of the listeners on shared values (P106), polled at every check point (lowering/signals/signal_values.rs)
- SIGNAL_
LISTEN signal_listen(kind, id, argument): starts the timer on·every·id,on every 5 seconds {…}(LISTEN_EVERY, ms),on frame {…}(LISTEN_FRAME, ms; every frame of the paint window while it shows, without a window once),on every monday at 9:00 {…}andat 9:00 {…}(LISTEN_CLOCK, weekdays · CLOCK_WEEKDAYS + minute of day, the weekdays a mask with bit 0 Sunday … bit 6 Saturday, 0 once at the next such local time)- SIGNAL_
POLL - SIGNAL_
WATCH - SLEEP
sleep(seconds), the prelude word; it callssleep_ms(milliseconds), the host word that pauses- SLEEP_
MS - SYSTEM_
VALUE system_value(name): the machine’sbatterypercent,charging,online,dark mode(system_values.rs)- SYSTEM_
VALUES - The system values, and whether each is a yes/no value
- TEXT_
COVERAGE text_coverage(words, size): the words set in a sans-serif fontsizepixels high (card paint-text, lib/draw.warp label): [width, height, then how much each pixel is covered, 0 to 255, row by row]; the browser’s canvas 2D fillText in the playground, a system font through ab_glyph natively (src/graphics/text_raster.rs)- TIMER_
HANDLER_ PREFIX on·every·0: the handler of the firston every … {…}- TIME_
OF_ DAY - The local time of day in milliseconds since midnight, what the word
timeis compared with a duration (src/numbers/units.rs) - VIEW_
HEIGHT - VIEW_
WIDTH - the size a picture gets: the playground’s output pane, natively the paint window’s first size (system_values.rs)
- WINDOW_
HEIGHT - WINDOW_
OPEN - Whether a window shows the pictures: natively the paint window until it closes (no before the first paint and
headless), on a page its canvas, always;
while window_open { … }is a drawing loop that ends with its window - WINDOW_
WIDTH - window.width/height (card make-width): the paint window’s inner size in points (the playground: the paintings’ frame in CSS pixels), writable; display.width/height the screen’s, read only (lowering/words/module_properties.rs)
Functions§
- link_
host_ words - Link sleep, random, random_below and clock, for a store of any state