Kernel syntax for when, unless, let/ec, and cond#5453
Merged
mflatt merged 4 commits intoracket:masterfrom Mar 13, 2026
Merged
Conversation
4bbe720 to
16a4529
Compare
sorawee
reviewed
Mar 4, 2026
ca3fe0a to
fb93531
Compare
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.
fb93531 to
e5a31e7
Compare
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.
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:
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-ifandraise-syntax-error-unlessinvocations. I also took advantage of the opportunity to improve some error messages, going from:to
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
to
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
condto use kernel syntax onlyMinimal modifications to the
condimplementation 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.