Skip to content

Commit 588cc52

Browse files
Merge pull request #508 from JuliaSymbolics/myb/upgrade
Add upgrade guide
2 parents 4a926c6 + 671e2ec commit 588cc52

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

docs/pages.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ pages = Any["index.md",
33
"manual/rewrite.md",
44
"manual/interface.md",
55
"manual/codegen.md"],
6-
"api.md"
6+
"api.md",
7+
"upgrade.md"
78
]

page/upgrade.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Upgrade to SymbolicUtils v1
2+
3+
The version 1 of SymbolicUtils utilizes
4+
[Unityper](https://github.com/YingboMa/Unityper.jl) to speed up the compilation
5+
time. We introduce a new type `BasicSymbolic <: Symbolic` to represent all the
6+
previous types `Sym`, `Term`, `Add`, `Mul`, `Pow` and `Div`. Since
7+
`BasicSymbolic` is a concrete type, checking `x isa Sym` or `x isa Pow` no
8+
longer works. Instead, one should use `issym(x)` or `ispow(x)` to check the
9+
"type" of the expression. Also, note that if one does not need to work on a
10+
specific symbolic representation, `issym(x)` and `isterm(x)` should be replaced
11+
by `x isa Symbolic && !istree(x)` and `istree(x)` to be more generic.
12+
Furthermore, dispatching on `Sym`, `Term`, etc no longer works. Instead, a
13+
function that takes `BasicSymbolic` should check the type of the expression
14+
using a `if` statement to select the right code path.
15+
16+
Although we don't have `Sym`, `Term`, etc in the Julia type system anymore, we
17+
still provide convenient constructors for them. For example, `Sym{Real}(:x)`
18+
would still work. For constructor that takes a collection like `Term`s, we
19+
recommend directly construct `Any` element type constructors like `Term(f,
20+
Any[x1, x2])` to reduce extra memory allocation and compile time.

0 commit comments

Comments
 (0)