Repository navigation
Docs: program arguments after --, sort idioms, channels of different types, equality and order idioms - #151
Merged
Merged
Conversation
rendro
added this pull request to stack #150
October 24, 2026 04:28
`silt run main.silt -- --help` printed silt's run help instead of running the program with `--help`: run (and disasm) looked for a help flag among all their arguments, past the `--` too. So did the watcher: `silt run -w main.silt -- --help` ran the program once and stopped watching. All three now look before `--` only (cli::help::asks_for_help). `check` and `test` were right already: check stops reading its flags at `--`, and test rejects `--` (it takes no program arguments). `silt run --help` names the separator: the usage line ends in `[-- <args>...]`, an option line says what it does, and an example passes an argument. getting-started's tooling block shows it too. Tests: goldens cli/run/program_args__a_help_flag_after_the_separator_is_the_program_s (package case, `silt run -- --help -h` prints both), cli/disasm/program_args__... (disassembles), cli/run/run_help__names_the_program_arguments (the help text); tests/cli watch_double_dash_separator_tests::run_watch_with_help_after_separator_watches_and_forwards_arg. All fail on the base.
list.sort says how to sort descending (`|> list.reverse`); list.sort_by says that it is stable, that a tuple key sorts by its parts in turn, and that a negated number key sorts descending, with an example that ranks players by score, highest first, then by name; list.sort_with that `Compare.compare(b, a)` sorts descending by any key. Each example runs, and its `--` comments are its output.
concurrency.md gains "Receiving from channels of different types": the operations of one channel.select and the channels of one stream.merge are of one type, so declare an enum with a variant for each kind of message, stream.map each channel into it and stream.merge them; one match handles them all, and the merged channel closes when its inputs have. Its example runs (`3 events`). channel.select's reference section points to it. Two notes promised what silt has decided against: stream.md's "Forward compatibility" (method-form dispatch `s.map(f)` once silt grows a Stream trait) and bytes.md's last note (a future `Bytes` literal and method-form access, with programs "forward-compatible"). A dot after a value names a field, and silt makes no compatibility promises: both are gone.
traits.md gains "Equality and order idioms", at the end of Built-in Traits, and the sealed rule points to it: what to write when a type should compare by something other than its structure. Normalise once in a constructor function; key a map by an id; key records that hold a function by their names; sort by a key (tuple keys, `|> list.reverse`, `list.sort_with`); find duplicates by a key with `list.unique_by`; order versions as records, field by field. One example program shows each; it runs, and its `--` comments are its output.
A hand-written `trait Equal for T`, `trait Compare for T` or `trait
Hash for T` is an error that says to remove the impl; now it also says
where the ways to compare by something else are:
= help: to compare, order or hash by something else (a key, a
normalised value), see "Equality and order idioms" in
docs/language/traits.md
(`Number`'s error has no such line.) The one change in src/typechecker
is in reject_sealed_trait_impls (lane E told first). traits.md's
example of the error shows the line.
Tests: golden typecheck/traits/sealed_traits__the_help_points_at_the_idioms
(fails on the base: no help); number__sealed now pins that Number's
error does not point there.
`silt test x_test.silt -- a` said "unknown flag '--'". It is refused still (a test is called with no arguments, so nothing could read them), but the message says so: "silt test takes no program arguments: '--' passes arguments to a program run by 'silt run'", then the usual "Run 'silt test --help' for usage." Test: golden cli/test/program_args__the_separator_is_refused (fails on the base: the old message).
rendro
force-pushed
the
w2/docs-and-idioms
branch
from
October 24, 2026 06:27
80cd770 to
c8280b4
Compare
rendro
marked this pull request as ready for review
October 24, 2026 12:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lane D, PR 3 of 4 (wave 2). Stacked on #149.
--are the program's,--helpincluded. Three places scanned every argument for--help: run, disasm and the watcher. One helper,cli::help::asks_for_help, now looks only before--. The run subcommand's help names-- <args>...and has an example. Tests that fail on the base: goldens cli/run/program_args__a_help_flag_after_the_separator_is_the_program_s, cli/disasm/program_args__*, cli/run/run_help__names_the_program_arguments; cli test run_watch_with_help_after_separator_watches_and_forwards_arg.|> list.reverse), sort_by stable with tuple keys and a negated key, sort_with withCompare.compare(b, a).New texts await the owner's approval before merge.
Checks: whole suite, clippy both ways, fmt, rustdoc, no-default-features check.