I'm trying to port this Python class:

class Env(dict):
    "An environment: a dict of {'var':val} pairs, with an outer Env."
    def __init__(self, parms=(), args=(), outer=None):
        self.update(zip(parms, args))
        self.outer = outer
    def find(self, var):
        "Find the innermost Env where var appears."
        return self if (var in self) else self.outer.find(var)

Haven't even got to the `find` method yet! :( ...this is what I've done:

Environment type:

julia> type Env
           data::Dict
           outer::Nullable{Env}
           Env() = new(Dict(), Nullable{Env}())
       end


Outer constructor:

julia> function Env(parms::Tuple, args::Tuple, outer::Env)
           Env(Dict(zip(parms, args)), Nullable(outer))
       end
Env


So far so good:

julia> parms = (:foo, :bar, :baz);
 
julia> args = (1, 2, 3);
 
julia> outer = Env()
Env(Dict{Any,Any}(),Nullable{Env}())


I've spent a lot of time trying to understand this, without success:

julia> inner = Env(parms, args, outer)
ERROR: `convert` has no method matching convert(::Type{Env}, 
::(Symbol,Symbol,Symbol), ::(Int32,Int32,Int32), ::Env)
 in call at base.jl:35


I'll have to go to work before soon, I know this'll be itching my head all 
day long! :P

What am I doing wrong? or How many things am I doing wrong? :O

Thanks in advance!

Reply via email to