Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Provisional API: This reference documents current compiler behavior. Compatibility is not yet promised.

src/components/printf-format.x

Var values in printf-family formats.

Design notes

A printf-family call whose format is a static literal passes each Var value the format consumes as the C type its conversion reads: a numeric conversion converts the value through Var.convert, %c and a * width or precision read an int, and %s displays it through Var.str. The format is read once, left to right. A Var value that no conversion consumes, or one at a conversion with no native reading, is an error. Each family member is one call pattern, keyed by its callee.

Each definition precedes the definitions that call it: the compiler settles whether a linked copy reaches a compile-time operation when the copy binds.