Skip to content

sift 1.31.0 — the builtins are code now

Choose a tag to compare

@jjba23 jjba23 released this 14 Nov 11:09
· 21 commits to trunk since this release
ae9b6ce

The second half of the standard library — the names an implementation compiled
in — used to be a file of prose. It is source now, and Racket is read the way
its own reader reads it.

A jump to car lands in code. car is in libguile and no installed file
defines it, so sift asks the implementation once and writes the answer as a
file in the dialect it describes: a procedure becomes a define or defun with
its docstring, a macro a define-macro or defmacro, and a value a define or
defvar — or, in Scheme, a define documented by the comment above it, because
Scheme has no docstring slot for a value.

;; sift --- the names GNU Guile 3.0.9 documents about itself
;; sift: version 3.0.9

(define (log10 x)
  "Return the base-10 logarithm of x."
  #f)

That file is read by the same reader as everything else, so a jump lands in code
and the hover is the hover of any other definition. A hover also falls back to
the comment above a definition that carries no docstring, which is how a Lisp
has always documented a value.

Actual code comes first. Every definition site is ranked, and the generated
file is last: a project, a required library and the installation's own sources
are offered before it. Against a real Guile, car resolves to srfi-17.scm
and map to srfi-1.scm, base.scm or boot-9.scm; log10 — which only the
compiled implementation defines — resolves to the generated file. The bespoke
### index parser is gone, and the cache version is bumped with the format.

Racket, read as Racket. Twelve things the first Racket release read as if
it were Scheme:

  • a backslash escapes the next character of an identifier, so foo\( is one
    name rather than an unterminated list;
  • #lang may follow the shebang that makes a module executable;
  • {...} is another spelling of (...) — a list, kept as written, and a quoted
    brace list stays inside its quote;
  • #u8(...) is Scheme's bytevector; a Racket file now says so instead of
    reading it silently;
  • :height is an identifier in Racket, and foo:bar carries no package marker;
  • .scrbl is Scribble, whose at-expression reader sift does not implement, so
    it is no longer claimed as Racket or offered to the formatter and editors —
    collapsing @verbatim{a b} is corruption;
  • a dialect marker counts only where a directive can be written, not in a
    comment or a string;
  • internal-define is Scheme's rule: Racket allows a definition interleaved
    with expressions in a body;
  • a case key and a match/match* subject are expressions, so
    clause-brackets reads the clauses after them;
  • (match (build-value a b) [p r]) brackets the clause, not the call around the
    subject, and a syntax-case literals list is not a clause;
  • a match pattern is data all the way down, except where ?, app and ==
    evaluate a sub-expression — an if-without-else fix can no longer rewrite a
    macro pattern;
  • lint --checker NAME respects the dialect the checker is for, as its
    docstring always promised.

The suite is guarded. A test written inside another test never runs, and
the run is green anyway. One was: a missing parenthesis made a test part of
the test above it, and two assertions passed by never executing.
tests/suites.scm now reads every test file with sift's own reader and fails
when a test is not a direct child of a suite.

Full Changelog: v1.30.0...v1.31.0