Hi,

I was wondering what is the best way going about the following issue. 
Suppose I have a type with few outer constructors which I name differently, 
and I want Julia to recognize these functions as constructors of that type. 
For example

type SomeType <: SomeAbstract
  name::ASCIIString
  value::Int
end

TypeA(value::Int) = SomeType("A", value)
TypeB(value::Int) = SomeType("B", value)

In this case, I have two pseudo-types, TypeA and TypeB, which have the same 
structure and are only different by their state. The problem with this 
approach is that now TypeA and TypeB are functions and not datatypes, thus, 
I cannot use operations defined on datetypes like checking for subtyping (TypeA 
<: SomeAbstract), or overloading type construction using call. 

Clearly, I could have defined two types which have exactly the same 
structure but this seems wrong to me as it involes code replication. 
Another possible solution is to define a macro which defines the type and 
its outer constructor, and I would call the macro to define TypeA and 
TypeB. Nonetheless, I was wondering if there was a way to tell Julia that 
the functions TypeA and TypeB are in fact constructors of SomeType. I'd be 
glag to hear about other solutions as well. 

Uri


Reply via email to