> `const A = T` is what `typealias A T` lowered to when it doesn't
have type parameters
I wanted to inspect the output of this lowering pass, but `@code_lowered`
was apparently not what I was looking for (at least, `@code_lowered
:(typealias Foo Int)` didn't work...).
However, I understand your statement as follows:
`typealias A T` is equivalent to `const A = T`, while `typealias A{S} T{S}`
does something more involved? What does `typealias A{S} T{Foo,S}` do? I
assume these are not possible using `const <foo> = <bar>` constructs, right?
// T
On Friday, October 30, 2015 at 1:45:37 PM UTC+1, Yichao Yu wrote:
>
> On Fri, Oct 30, 2015 at 8:29 AM, FANG Colin <[email protected]
> <javascript:>> wrote:
> > I have got the same confusion. Any ideas?
> >
> > I have even seen usage of A = T (no const)
> > (http://docs.julialang.org/en/release-0.4/manual/types/#type-unions),
> is it
> > supposed to be bad (slow) because it is a global variable?
> >
>
> no const will have performance issue since it's a global.
> `const A = T` is what `typealias A T` lowered to when it doesn't have
> type parameters. In this case, it's just a matter of style. Being
> consistent within a file is probably better but you can pick whichever
> you prefer.
>
> >
> >
> > On Thursday, November 6, 2014 at 3:38:41 PM UTC, Steven G. Johnson
> wrote:
> >>
> >> Given a type T, what is the difference in practice between
> >> typealias A T
> >> and
> >> const A = T
> >> ?
> >>
> >> There seems to be some disagreement over which one to use (e.g.
> >>
> https://github.com/JuliaLang/Compat.jl/commit/8211e38ac7d8448298a2bb3ab36d6f0b6398b577).
>
>
> >>
> >> My impression is that there is no difference, and that the only
> advantage
> >> of a typealias is that it can be parameterized. Is that right?
> >>
> >> If they are equivalent, what is the Julian style? Even in Julia Base
> it
> >> doesn't seem to be entirely consistent.
>