Being very new to Racket, I see in the documentation percentage-sign suffixes "%" or "<%>". What do these mean? Are there any documents explaining these?
Racket’s grammar of identifiers is far more generous than that of a pederstian language. So % @ #! & * and such things can be, and often are, part of ordinary identifiers.
Racket’s style comes with a number of (unenforced) conventions. So the ending of % in my-class% says “I am the name of a class.” Similarly. <%> signals I am the name of an interface.
I asked ChatGPT for a table over similar conventions.
Looks correct to me.
| Convention | Usually means | Example | Notes |
|---|---|---|---|
? suffix |
predicate / boolean-valued function | empty?, boolean? |
A question-like name answers yes/no. (Racket Documentation) |
! suffix |
mutation / setter / destructive update | set!, set-box!, vector-set! |
The “bang” convention is inherited from Scheme/Lisp style. (Racket Documentation) |
% suffix |
class | object%, game-state% |
The convention discussed in the Discourse thread. (Racket Discourse) |
<%> suffix |
interface | dc<%>, area<%> |
Visually suggests an interface-ish “shape.” (Racket Discourse) |
^ suffix |
unit signature | game-context^ |
Used with Racket’s unit system. (Racket Documentation) |
@ suffix |
unit | testing-context@ |
Pairs naturally with ^ signatures. (Racket Documentation) |
#% prefix |
kernel / language-building identifier | #%app, #%module-begin |
Signals “extremely special” identifiers, often relevant when defining languages. (Racket Documentation) |
/ inside name |
“with”, specialization, or variant | call/cc, foldl/steps |
The style guide glosses / as a preposition like “with.” (Racket Documentation) |
- between words |
normal word separator | render-game-state |
Preferred over camelCase or underscores in Racket style. (Racket Documentation) |
| data-type prefix | operation on a main data type | board-free-spaces, syntax-local-value |
Common for functions in an ADT/module; resembles struct selector names. (Racket Documentation) |
| type-ish suffix on local variables | variable’s representation/type | name-string, name-symbol |
Especially useful when the same data appears in multiple guises. (Racket Documentation) |
_ as placeholder |
ignored value / wildcard | _ in match or syntax patterns |
The style guide discourages underscores in ordinary names, but accepts _ as a placeholder. (Racket Documentation) |
It added this table:
| Convention | Usually means | Example | Notes |
|---|---|---|---|
-> inside name |
conversion | string->symbol, number->string |
Read aloud as “to.” |
* suffix or infix |
variant / generalized form | let*, for*, regexp-match* |
Often means sequential, repeated, or “all matches,” depending on context. |
: inside name |
hierarchy / refinement | exn:fail:contract |
Common in exception and struct-type names. |
... in syntax patterns |
repetition | (x ...) |
This one is syntactic, not merely a naming convention. |
Source: https://chatgpt.com/share/6a314b0f-1d84-83e8-ae24-2eb7f2bdb915
I use 1security* to indicate that the variable stands for a possibly empty list of 1security -s. Similarly, 1security+ denotes a non-empty one. Thanks Kleene.
(Yes, a good sw dev would distinguish the two via a char at the beginning of the identifier, but I tried *1security and it doesn’t feel Kleene-ish.)
The style guide
describes these suffixes, but note MF's point that these are stylistic
and not enforced by the language. %@#!&* is a valid identifier ![]()