Skip to content

returning a metamethod from a macro #66

@Qiyamah

Description

@Qiyamah
	function gen_sym(pattern,body)
		quote
    		@metafunction testfun($pattern) begin
    		    $(body...)
    		end
    	         end
	end

	@macromethod test(pattern,begin *{body} end) begin
	    pattern_tree = analyze(pattern,current_module()).child
	    #matchfun = matcher(pattern,@currentmodule)
	    if pattern_tree.head.sym != :call
	    	error("not a function call")
	    end
	    fun = gen_sym(pattern,body)
    	quote
    		$fun
    	end
	end

macroexpand(:(@test f(:E{x,2},:T{y,Int}) begin
                           f(x+y)
                     end))

results in

:($(Expr(:error, MethodError(haskey, (ExpressionPatterns.Dispatch.TopMetaTables.MetaModuleTable(Dict{Symbol,ExpressionPatterns.Dispatch.Structure.MetaMethodTable}(), Set{Symbol}()), :($(Expr(:globalref, Main, :testfun)))), 0x0000000000005886))))

I can't see why?
Why can't i return a metafunction?

thanks

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions