Skip to content

Add homogenous dict types #499

Open
Open
@mtshiba

Description

@mtshiba

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCNew specifications of ErgenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions