Skip to content

Kernel syntax for when, unless, let/ec, and cond#5453

Merged
mflatt merged 4 commits intoracket:masterfrom
jesboat:pr-kernelify-when-unless-letec-cond
Mar 13, 2026
Merged

Kernel syntax for when, unless, let/ec, and cond#5453
mflatt merged 4 commits intoracket:masterfrom
jesboat:pr-kernelify-when-unless-letec-cond

Conversation

@jesboat
Copy link
Copy Markdown
Contributor

@jesboat jesboat commented Feb 28, 2026

Note: the diff for this PR is best viewed with whitespace changes hidden.

Commit log:

racket/private: new raise-syntax-error-{if,unless} helpers

There is a very common pattern in the implementation of low-level macros:

(if something
    (void)
    (raise-syntax-error #f constant-string local-variable))

Introduce the appropriate abstraction to handle them.

This does not introduce uses; rather, uses will be added as more of the core syntax is centralized and some of the implementations are slightly modernized. See #5406 for more on that effort.

racket/private/define-et-al: use kernel syntax in when/unless

This is quite straightforward; mostly it's just changing a cond where the first pile of branches do error checking to a handful of raise-syntax-error-if and raise-syntax-error-unless invocations. I also took advantage of the opportunity to improve some error messages, going from:

bad syntax
missing test expression and body
missing body

to

bad syntax     [when used as an identifier macro or an improper list]
bad syntax (missing test expression and body)
bad syntax (missing body)

This is part of a larger effort to centralize and modernize some core syntax constructs; see #5406 for more on that.

racket/private/define-et-al: use kernel syntax for let/ec

Quite straightforward. This also improves the error messages from

bad syntax

to

bad syntax     [when used as an identifier macro or an improper list]
bad syntax (missing identifier and body)
bad syntax (missing body)

This is part of a larger effort to centralize and modernize some core syntax constructs; see #5406 for more on that.

racket/private/cond: modify cond to use kernel syntax only

Minimal modifications to the cond implementation to only use kernel syntax. Note that it still uses non-kernel functions.

This is part of a larger effort to centralize and modernize some core syntax constructs; see #5406 for more on that.

@jesboat jesboat force-pushed the pr-kernelify-when-unless-letec-cond branch 2 times, most recently from 4bbe720 to 16a4529 Compare March 3, 2026 21:33
@jesboat jesboat force-pushed the pr-kernelify-when-unless-letec-cond branch 2 times, most recently from ca3fe0a to fb93531 Compare March 6, 2026 15:09
jesboat added 4 commits March 6, 2026 11:59
There is a very common pattern in the implementation of low-level macros:

    (if something
        (void)
        (raise-syntax-error #f constant-string local-variable))

Introduce the appropriate abstraction to handle them.

This does not introduce uses; rather, uses will be added as more of the core
syntax is centralized and some of the implementations are slightly modernized.
See racket#5406 for more on that effort.
This is quite straightforward; mostly it's just changing a cond where
the first pile of branches do error checking to a handful of
`raise-syntax-error-if` and `raise-syntax-error-unless` invocations.
I also took advantage of the opportunity to improve some error messages,
going from:

    bad syntax
    missing test expression and body
    missing body

to

    bad syntax    [when used as identifier or in improper list]
    bad syntax (missing test expression and body)
    bad syntax (missing body)

This is part of a larger effort to centralize and modernize some core syntax
constructs; see racket#5406 for more on that.
Quite straightforward. This also improves the error messages from

    bad syntax

to

    bad syntax   [when used as identifier macro or in an improper list]
    bad syntax (missing identifier and body)
    bad syntax (missing body)

This is part of a larger effort to centralize and modernize some core syntax
constructs; see racket#5406 for more on that.
Minimal modifications to the `cond` implementation to only use kernel
syntax. Note that it still uses non-kernel functions.

This is part of a larger effort to centralize and modernize some core syntax
constructs; see racket#5406 for more on that.
@jesboat jesboat force-pushed the pr-kernelify-when-unless-letec-cond branch from fb93531 to e5a31e7 Compare March 6, 2026 17:18
@mflatt mflatt merged commit 086c558 into racket:master Mar 13, 2026
8 checks passed
@jesboat jesboat deleted the pr-kernelify-when-unless-letec-cond branch March 13, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants