feat(lang): L11 views and templates - the UI is markup, not code
A `view Name { field = x; function q(..); on e(..) }` declaration is the one bridge between a
program and its UI: it writes view_<name>() -> UiView, whose model is a Value of every field and
whose call runs a query or an event by name.
ludic.ui is a template runtime:
- HTML-shaped XML screens and components, loaded at run time;
- {expression} bindings, if/else/each, props, slots, per-instance state;
- on-press / onclick actions (event, set, emit);
- component libraries (export="true", <import src as>).
Styling:
- stylesheets in <style> or importable .lss files (@import);
- CSS selectors (#id, .class, [attr=v], descendant and > combinators, :hover, :disabled,
:first-child, :last-child, :nth-child, :not) weighed by specificity;
- the box model and flex under CSS's property names.
Also:
- default parameters, and positional-then-named calls;
- Value gains a float kind;
- a function shadowing a runtime one is refused;
- an index is evaluated before the slice is read;
- runtime errors name the right file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
334469ef61
commit
66a2bc2214
64 changed files with 74806 additions and 63975 deletions
5
examples/rejected/default_missing.ludic
Normal file
5
examples/rejected/default_missing.ludic
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# L11: a call leaves out only what has a default
|
||||
program DefaultMissing {
|
||||
function f(a: int, b: int = 2) -> int { return a + b }
|
||||
entry { print(f(b: 3)) }
|
||||
}
|
||||
5
examples/rejected/default_unknown.ludic
Normal file
5
examples/rejected/default_unknown.ludic
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# L11: a named argument names a parameter the function has
|
||||
program DefaultUnknown {
|
||||
function f(a: int, b: int = 2) -> int { return a + b }
|
||||
entry { print(f(1, c: 3)) }
|
||||
}
|
||||
5
examples/rejected/positional_after_named.ludic
Normal file
5
examples/rejected/positional_after_named.ludic
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# L11: positional arguments come first, then named ones
|
||||
program PositionalAfterNamed {
|
||||
function f(a: int, b: int = 2) -> int { return a + b }
|
||||
entry { print(f(a: 1, 2)) }
|
||||
}
|
||||
9
examples/rejected/view_untyped.ludic
Normal file
9
examples/rejected/view_untyped.ludic
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# a view field that is not a bare global has to say its type
|
||||
import "ludic.ui"
|
||||
program ViewUntyped {
|
||||
var a: int = 1
|
||||
view Sums {
|
||||
total = a + 2
|
||||
}
|
||||
entry { print(view_sums().name) }
|
||||
}
|
||||
8
examples/rejected/view_without_ui.ludic
Normal file
8
examples/rejected/view_without_ui.ludic
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# a view is for templates, which ludic.ui shows
|
||||
program ViewWithoutUi {
|
||||
var a: int = 1
|
||||
view Sums {
|
||||
a = a
|
||||
}
|
||||
entry { print(a) }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue