diff --git a/src/TermInterface.jl b/src/TermInterface.jl index f1e311e..c2de6f1 100644 --- a/src/TermInterface.jl +++ b/src/TermInterface.jl @@ -109,7 +109,7 @@ function metadata end """ - maketerm(T, head, children, type=nothing, metadata=nothing) + maketerm(T, head, children, type, metadata) Constructs an expression. `T` is a constructor type, `head` and `children` are the head and tail of the S-expression, `type` is the `type` of the S-expression. @@ -125,8 +125,7 @@ the sub-expression. `T` will be the type of the outer expression. Packages providing expression types _must_ implement this method for each expression type. -If your types do not support type information or metadata, you still need to accept -these arguments and may choose to not use them. +Giving `nothing` for `type` or `metadata` results in a default being selected. """ function maketerm end diff --git a/src/expr.jl b/src/expr.jl index 2a5f1d6..5b19b98 100644 --- a/src/expr.jl +++ b/src/expr.jl @@ -10,6 +10,6 @@ children(e::Expr) = e.args operation(e::Expr) = iscall(e) ? first(children(e)) : error("operation called on a non-function call expression") arguments(e::Expr) = iscall(e) ? @view(e.args[2:end]) : error("arguments called on a non-function call expression") -function maketerm(::Type{Expr}, head, args, type=nothing, metadata=nothing) +function maketerm(::Type{Expr}, head, args, type, metadata) Expr(head, args...) end diff --git a/test/runtests.jl b/test/runtests.jl index 8508a2c..0e9e5dc 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -9,7 +9,7 @@ using Test @test arguments(ex) == [:a, :b] @test isexpr(ex) @test iscall(ex) - @test ex == maketerm(Expr, :call, [:f, :a, :b]) + @test ex == maketerm(Expr, :call, [:f, :a, :b], nothing, nothing) ex = :(arr[i, j]) @@ -18,5 +18,5 @@ using Test @test_throws ErrorException arguments(ex) @test isexpr(ex) @test !iscall(ex) - @test ex == maketerm(Expr, :ref, [:arr, :i, :j]) + @test ex == maketerm(Expr, :ref, [:arr, :i, :j], nothing, nothing) end