Skip to content

Dict syntax is getting me down #6739

Closed
@JeffBezanson

Description

I have not been enjoying that => is not first-class. It works well for simple dict literals ([a=>b, c=>d]), but the other forms cause trouble. For example I defined

typealias AbstractValue Dict{Symbol,LatticeElement}

but one cannot make a Dict of this type using this definition. You have to write (Symbol=>LatticeElement)[...] every time.

In the near future it will be possible to write Dict( (a,b) for i in x ), which makes a pretty good dict comprehension syntax without any special code in the front end. For literals this would be Dict([(a,b), (c,d), ...]), which starts to suffer from too much punctuation. One way to solve this is to make => a type, so you could write Dict(a=>b, c=>d, ...). => would not be iterable, so this would not be ambiguous. This would eliminate all special dict syntax. It would also make it more obvious how to write a typed empty Dict: you just pass 0 arguments.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    needs decisionA decision on this change is needed

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions