Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix punctuatins. #29991

Closed
wants to merge 11 commits into from
11 changes: 6 additions & 5 deletions doc/src/manual/metaprogramming.md
Expand Up @@ -129,7 +129,7 @@ julia> Symbol(:var,'_',"sym")
In the context of an expression, symbols are used to indicate access to variables; when an expression
is evaluated, a symbol is replaced with the value bound to that symbol in the appropriate [scope](@ref scope-of-variables).

Sometimes extra parentheses around the argument to `:` are needed to avoid ambiguity in parsing.:
Sometimes extra parentheses around the argument to `:` are needed to avoid ambiguity in parsing:

```jldoctest
julia> :(:)
Expand Down Expand Up @@ -710,13 +710,13 @@ julia> @macroexpand @assert a==b "a should equal b!"
```

There is yet another case that the actual `@assert` macro handles: what if, in addition to printing
"a should equal b," we wanted to print their values? One might naively try to use string interpolation
"a should equal b!", we wanted to print their values? One might naively try to use string interpolation
in the custom message, e.g., `@assert a==b "a ($a) should equal b ($b)!"`, but this won't work
as expected with the above macro. Can you see why? Recall from [string interpolation](@ref string-interpolation) that
an interpolated string is rewritten to a call to [`string`](@ref). Compare:

```jldoctest
julia> typeof(:("a should equal b"))
julia> typeof(:("a should equal b!"))
String

julia> typeof(:("a ($a) should equal b ($b)!"))
Expand Down Expand Up @@ -907,7 +907,7 @@ When a significant amount of repetitive boilerplate code is required, it is comm
it programmatically to avoid redundancy. In most languages, this requires an extra build step,
and a separate program to generate the repetitive code. In Julia, expression interpolation and
[`eval`](@ref) allow such code generation to take place in the normal course of program execution.
For example, consider the following custom type
For example, consider the following custom type:

```jldoctest mynumber-codegen
struct MyNumber
Expand Down Expand Up @@ -1100,7 +1100,7 @@ When defining generated functions, there are four main differences to ordinary f
Due to an implementation limitation, this also means that they currently cannot define a closure
or generator.

It's easiest to illustrate this with an example. We can declare a generated function `foo` as
It's easiest to illustrate this with an example. We can declare a generated function `foo` as:

```jldoctest generated
julia> @generated function foo(x)
Expand All @@ -1119,6 +1119,7 @@ have to know whether you're calling a regular or generated function. Let's see h
```jldoctest generated
julia> x = foo(2); # note: output is from println() statement in the body
Int64
4
nagexiucai marked this conversation as resolved.
Show resolved Hide resolved

julia> x # now we print x
4
Expand Down