Skip to content

Commit

Permalink
Merge branch 'autounravel' of https://github.com/vectorgraphics/asymp…
Browse files Browse the repository at this point in the history
…tote into autounravel
  • Loading branch information
charlesstaats committed Dec 15, 2024
2 parents 2735aad + 77ba9cd commit 1b157a7
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions doc/asymptote.texi
Original file line number Diff line number Diff line change
Expand Up @@ -6537,41 +6537,40 @@ feature request at @uref{https://github.com/vectorgraphics/asymptote/issues}.
@node When fields are autounraveled
@subsection When fields are autounraveled

If a struct contains fields (including functions) that are declared with
@code{autounravel}, these fields will be unraveled from the struct at:
If a @code{struct} contains fields (including functions) that are declared with
@code{autounravel}, these fields will be unraveled from the @code{struct} at:

@itemize
@item
the end of the struct definition;
the end of the @code{struct} definition;
@item
a @code{typedef import} statement, if the struct is the argument for one of
a @code{typedef import} statement, if the @code{struct} is the argument for one of
the type parameters;
@item
an @code{unravel} or @code{access} statement that unravels the struct from
a module or outer struct (for instance,
an @code{unravel} or @code{access} statement that unravels the @code{struct} from
a module or outer @code{struct} (for instance,
@code{from rational access rational;} would make the @code{+} operator available
from the struct @code{rational} defined in @code{rational.asy});
from the @code{struct} @code{rational} defined in @code{rational.asy});

@item
A @code{typedef} statement like @code{typedef rational.rational rat;}
that renames a struct.
that renames a @code{struct}.
@end itemize

@node Where autounravel is legal
@subsection Where @code{autounravel} is legal

For the most part, @code{autounravel} can be used in the same
places as @code{static}. However, there are certain places
where @code{autounravel} will give an error.

Specifying @code{autounravel} at the top level of a module (i.e.,
outside of any struct or function) is an error, whereas @code{static}
gives only a warning. If top-level @code{autounravel} were allowed,
The @code{autounravel} modifier implies @code{static} and can be used
in many of the same places as @code{static}. However, specifying
@code{autounravel} at the top level of a module (i.e.,
outside of any structure or function) is an error, whereas @code{static}
gives only a warning. @footnote{If top-level @code{autounravel} were allowed,
a user might incorrectly assume that the field would be unraveled
whenever the module is @code{access}ed. The @code{static} modifier is allowed at
the top level because, while it does nothing, it does not mislead the user.
whenever the module is @code{access}ed. The @code{static} modifier
is allowed at the top level because, while it does nothing, it does
not mislead the user.}
In front of a @code{struct} definition or @code{typedef} statement,
@code{autounravel} is forbidden, because types cannot be autounraveled.
@code{autounravel} is forbidden because types cannot be autounraveled.
While @code{static static} results in an error,
@code{static autounravel} and @code{autounravel static} are both legal
and have exactly the same effect as @code{autounravel} alone.
Expand Down

0 comments on commit 1b157a7

Please sign in to comment.