Skip to main content

Module julia

Module julia 

Source
Expand description

Rendering the Julia CST. Spec §5.

One style: four spaces per level, # comments, one blank line between declarations. Four spaces because that is what the manual’s own style guide and every formatter for the language use, and because Julia has no gofmt to make the question moot.

Nothing is decided here. A Julia type reads left to right and carries its own length and element type, so unlike crate::c there is no declarator to split around a name: a field is the name, ::, and the type.

§# and not a docstring

Julia’s documentation form is a string literal above the declaration, which the parser attaches to the binding. It is an expression that runs when the file is loaded and it can only be attached to a binding Julia has a docsystem entry for — not, for instance, to one field of a struct. A # comment carries the same text, is attached to nothing, and cannot fail at load time. For a file whose whole content is type declarations, that is the honest form.

§$ is escaped in a string literal

Julia interpolates $name inside "…" (manual, “Strings”), so a const string PROMPT = "$HOME"; written through the C-family escape alone would be a file that either fails to load — UndefVarError: HOME — or, worse, loads with whatever HOME happens to name. It is escaped here, in the one place a Julia string literal is written.

Functions§

decl
Render one declaration, for a caller that has only one.
expr
Render one expression, for a caller assembling source by hand.
file
Render a whole file.
ident
The identifier a name renders as, for a caller assembling one.
statement
Render one statement, for a caller that has only one.
string_literal
A Julia string literal, quotes and escapes included.
type_
Render one type, for a caller that has only one.