Skip to content

Support value access for dictionaries/maps #324

Open
@niknetniko

Description

@niknetniko

We should add a special function for accessing values in a map, dictionary or object, since this is a common operation in languages that support the data structure.

In the DSL, we must be careful:

  • Ideally we want to use the Python syntax, i.e. a_dictionary["some_key"].
  • However, this gets tricky when using numeric keys, as there is no way to know the difference between dictionary access and array access syntactically.

Some options could include:

  • Not using square brackets in the DSL for dictionary access, instead reserving some other function name, e.g. a_dictionary.dict_get. This is less ideal, since we have to introduce magic functions with reserved names.
  • Distinguishing both cases based on the type of the variable, and requiring casts in cases where we don't know. First see if we know the type of the variable, then if we know the type of the key (e.g. non-numeric keys indicate dictionary), and otherwise require casts, e.g. dict(a_dictionary)[some_key].

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions