Hi,

I've came across the following scenario and I can't say if the behavior I'm 
seeing is a matter of design, or if it's bug. I think the simplest way 
would be to post the code producing the behavior, so here it is, 

julia> type SomeType
         name::ASCIIString
         value::Int
       end

julia> typealias TypeA SomeType
SomeType

julia> TypeA(value::Int) = SomeType("A", value)
SomeType

julia> TypeA(2)
SomeType("A",2)

julia> typealias TypeB SomeType
SomeType

julia> TypeB(value::Int) = SomeType("B", value)
SomeType

julia> TypeB(2)
SomeType("B",2)

julia> TypeA(2)
SomeType("B",2)

The unexpected behvior was the result of the last call, which I expected to 
be SomeType("A", 2). I'm guessing that the julia parser is replacing 
whatever code comes his way with the last typealias, thus, the second 
method definition overwrites the first. 

My goal was to construct a single type, and have constructors with 
different names to produce different kinds of instances. I don't want to 
defined types with different names only to distinguish between 
different instances that are only different in their state but not by the 
structure of their type. 

Uri


Reply via email to