Skip to content
This repository was archived by the owner on Dec 18, 2020. It is now read-only.
This repository was archived by the owner on Dec 18, 2020. It is now read-only.

Should there be a makeArray primitive, and for what? #27

Description

@Bastacyclop

Currently we have a makeArray primitive that works very much like an array literal, except that it works with elements that are expressions, instead of plain data like literals do. Currently we only generate code for makeArray if indices are constant (we know which element to pick at codegen time).

  1. Why can our normal array literals not contain arbitrary expressions?
  2. Should we generate code for non-constant indices, and how?
  3. Why do we need array literals when we can use array constructors like makeArray?

Personally, I would like to solve both of these questions by removing the makeArray primitive. Instead of plain data, normal array literals would take elements of expression kind.

Additonnaly, a selectArray -- or differently named high-level construct -- would also allow to create arrays as a combination of generate and select. This would generate C code with if statements or ternaries to pick the right element. If indices are constant, we should simplify the branching away.

@rise-lang/core

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions