|
1 | 1 | mutable struct Variable <: Expression |
2 | 2 | name::Symbol |
3 | | - value_type::DataType |
4 | 3 | subtype::Symbol |
5 | 4 | diff::Union{Function,Nothing} # FIXME |
6 | 5 | dependents::Vector{Variable} |
7 | | - description::String |
8 | | - flow::Bool |
9 | | - domain::AbstractDomain |
10 | | - size |
11 | | - context |
12 | 6 | end |
13 | 7 |
|
14 | | -Variable(name, |
15 | | - value_type = Any; |
16 | | - subtype::Symbol=:Variable, |
17 | | - dependents::Vector{Variable} = Variable[], |
18 | | - flow::Bool = false, |
19 | | - description::String = "", |
20 | | - domain = Reals(), |
21 | | - size = nothing, |
22 | | - context = nothing) = |
23 | | - Variable(name,value_type,subtype,nothing, |
24 | | - dependents,description,flow,domain,size,context) |
| 8 | +Variable(name; subtype::Symbol=:Variable, dependents::Vector{Variable} = Variable[]) = |
| 9 | + Variable(name, subtype, nothing, dependents) |
25 | 10 | Variable(name,args...;kwargs...) = Variable(name,args...;subtype=:Variable,kwargs...) |
26 | 11 |
|
27 | 12 | Variable(name,x::Variable) = Variable(name,x.value_type, |
@@ -71,10 +56,7 @@ Base.isone(ex::Expression) = isa(ex, Constant) && isone(ex.value) |
71 | 56 |
|
72 | 57 |
|
73 | 58 | # Variables use isequal for equality since == is an Operation |
74 | | -function Base.:(==)(x::Variable, y::Variable) |
75 | | - x.name == y.name && x.subtype == y.subtype && |
76 | | - x.value_type == y.value_type && x.diff == y.diff |
77 | | -end |
| 59 | +Base.:(==)(x::Variable, y::Variable) = (x.name, x.subtype, x.diff) == (y.name, y.subtype, y.diff) |
78 | 60 | Base.:(==)(::Variable, ::Number) = false |
79 | 61 | Base.:(==)(::Number, ::Variable) = false |
80 | 62 | Base.:(==)(::Variable, ::Constant) = false |
|
0 commit comments