Hacker News new | ask | show | jobs
by rattray 3051 days ago
Wow, a bunch of nice features here, named tuples, function argument destructuring... Also a bunch of syntax/parsing cleanups, hopefully for the best.
1 comments

When I first used named tuples in Swift I thought they'd be so great, no more _1 _2 or whatever. After using them a while, it gets a bit tiring and litters with repeated type info. A type alias for a named tuple would help with that. Any others have similar experiences? Or would they play out differently in Julia?
Wouldn't that just be a struct?
Like an ad-hoc anonymously typed struct. Only the members are named, so each time the type is specified it is with the member names, hence just using a type name is preferred. If it is really just used at one or two call sites and not propagated all is well, but invariably things tend to expand in use.
I still don't quite see why you wouldn't just use a named struct, but you can create a alias for the NamedTuple type

    const MyAlias = NamedTuple{(:a, :b),Tuple{Int64,Int64}}
    MyAlias((2, 3)) # (a = 2, b = 3)
Types are first class in Julia.