Actually, Pairs *are* type specialized, as can be seen by their definition.
# Pair
immutable Pair{A,B}
first::A
second::B
end
const => = Pair
Notice the {A,B} type parameters. The second `const => = Pair` in
combination with `=>` being infix, allows for convenient Dict construction
by
Dict("hey"=>1, "there"=>2)
It was kind of back and forth on whether we should just use a two-tuple for
this, but ultimately, it was decided to use a Pair type. We should
definitely provide some more documentation on this.
Cheers,
-Jacob
On Wed, Feb 4, 2015 at 11:58 AM, Seth <[email protected]> wrote:
> I stumbled across Pair by accident and didn't find anything in the way of
> docs, so I started playing with it and looking at the source.
>
> I can't figure out what the use case might be. It doesn't appear to be
> type-optimized; that is, it doesn't use type parameterization to provide
> speed/efficiency gains. It appears to allow Any=>Any, which I guess might
> be useful, but I don't see how it might be better than a tuple. Using it in
> lieu of an explicit type such as
>
> immutable Edge
> src::Int
> dst::Int
> end
>
> results in (my) code being an order of magnitude slower - I assume it's
> because I've specified the types of the members.
>
> What is the intended use case for the Pair type, and did I miss the
> documentation?
>
>