Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add homogenous dict types #499

Open
mtshiba opened this issue Mar 24, 2024 · 0 comments
Open

Add homogenous dict types #499

mtshiba opened this issue Mar 24, 2024 · 0 comments
Labels
enhancement New feature or request RFC New specifications of Erg

Comments

@mtshiba
Copy link
Member

mtshiba commented Mar 24, 2024

Currently, Erg doesn't have homogenous dict types.

dic: {Int: Str, Str: Float} = {1: "a", "b": 1.0}

A dictionary with Str as keys and Int as values is simply of type {Str: Int}.

We can write key/values of different types, but sometimes this spec is too elastic (especially for mutable Dict types).

Therefore, we propose to introduce homogenous dict types Dict(K, V)/Dict!(K, V).

dic: Dict(Str, Int) = {"a": 1, "b": 2}

The current heterogeneous dict types are kinds of structural types, just like record types, and are subtypes of the homogenous dict types. For example, {K1: V1, K2: V2} is a subtype of Dict(K1 or V1, K2 or V2).

@mtshiba mtshiba added enhancement New feature or request RFC New specifications of Erg labels Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request RFC New specifications of Erg
Projects
None yet
Development

No branches or pull requests

1 participant