tomtom
July 21, 2020, 12:52pm
#1
the following function:

```
function symident(n::Int)
rows = Vector{Expr}(undef, n)
temp = zeros(Int, n)
for i in Base.OneTo(n)
temp[i] = 1
rows[i] = Expr(:row, temp...)
temp[i] = 0
end
return Expr(:vcat, rows...)
end
```

gives warntypes that I don’t understand:

```
julia> @code_warntype symident(3)
Body::Any
│ %23 = Core._apply(Main.Expr, %22, temp)::Any
│ %32 = Core._apply(Main.Expr, %31, rows)::Any
└── return %32
```

seems like there’s some problem using the splatting operator `...`

?
please help. thanks.

tomtom
July 22, 2020, 3:06am
#2
minimal working examples:

```
f1() = (v = [:a, :b]; Expr(:row, v...) )
f2() = (v = [Expr(:call, :+, 1, 1), Expr(:call, :+, 2, 2)];
Expr(:row, v...) )
f3() = (v = [1, 2]; Expr(:row, v...) )
f4() = (v = [1, 2]; Expr(:vcat, v...) )
julia> @code_warntype f1()
julia> @code_warntype f2()
julia> @code_warntype f3()
julia> @code_warntype f4()
```

all functions `f1()`

to `f4()`

give warntypes.

I am not sure what you are expecting here, since `Expr`

has its `args`

in a `Vector{Any}`

:

```
julia> dump(Expr)
Expr <: Any
head::Symbol
args::Array{Any,1}
```

Since the primary use case for manipulating `Expr`

s is metaprogramming, this is intentional.

tomtom
July 22, 2020, 9:02am
#4
oh, I supposed that `args`

should be, e.g. in `Vector{Int}`

for `f4()`

.

that said, does those warntypes has performance overhead? or, could I just ignore all warntypes involving expressions and symbols? thanks.

Compared to what?

Possibly yes, but if your use case is metaprogramming, they should be irrelevant anyway.

Are you optimizing metaprogramming code? Having some context would help.

tomtom
July 22, 2020, 9:53am
#6
I’m trying to use `Reduce.jl`

to help generating some complicated equations (that I could not completed by hands). Anyway, I think the warntype overhead is very small compared to those used in working with the `REDUCE CSL`

.