Skip to content

Commit 96e33d9

Browse files
author
Alessandro
committed
reverted similarterm arguments structure for compatibility. version bump
1 parent 5a8490a commit 96e33d9

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "TermInterface"
22
uuid = "8ea1fca8-c5ef-4a55-8b96-4e9afe9c9a3c"
33
authors = ["Shashi Gowda <gowda@mit.edu>", "Alessandro Cheli <sudo-woodo3@protonmail.com>"]
4-
version = "0.1.1"
4+
version = "0.1.2"
55

66
[compat]
77
julia = "1"

src/TermInterface.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,23 @@ end
8383

8484

8585
"""
86-
similarterm(x, head, args; type=nothing, metadata=nothing)
86+
similarterm(x, head, args, symtype=nothing; metadata=nothing)
8787
8888
Returns a term that is in the same closure of types as `typeof(x)`,
8989
with `head` as the head and `args` as the arguments, `type` as the symtype
9090
and `metadata` as the metadata. By default this will execute `head(args...)`.
9191
`x` parameter can also be a `Type`.
9292
"""
93-
similarterm(x, head, args; type=nothing, metadata=nothing) =
94-
similarterm(typeof(x), head, args; type=type, metadata=nothing)
95-
similarterm(x::Type{Expr}, head, args; type=nothing, metadata=nothing) = Expr(head, args...)
96-
function similarterm(x::Type{T}, head::T, args; type=nothing, metadata=nothing) where T
93+
similarterm(x, head, args, symtype=nothing; metadata=nothing) =
94+
similarterm(typeof(x), head, args, type; metadata=nothing)
95+
96+
similarterm(x::Type{Expr}, head, args, symtype=nothing; metadata=nothing) = Expr(head, args...)
97+
function similarterm(x::Type{T}, head::T, args, symtype=nothing; metadata=nothing) where T
9798
if !isterm(T) head else head(args...) end
9899
end
99100
export similarterm
100101

102+
include("utils.jl")
103+
101104
end # module
102105

src/utils.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""
2+
is_operation(f)
3+
4+
Returns a single argument anonymous function predicate, that returns `true` if and only if
5+
the argument to the predicate satisfies `isterm` and `gethead(x) == f`
6+
"""
7+
is_operation(f) = @nospecialize(x) -> isterm(x) && (gethead(x) == f)
8+
export is_operation

0 commit comments

Comments
 (0)