Skip to content

use Value abstraction for std::variant<Any> #19

@aardhyn

Description

@aardhyn

It'd becoming a burden to constantly query and check the underlying types of literal values.

class Value final {}; // could be literal or variable. could be number, string, array, etc.

This type would be intentionally non-generic. throwing runtime type exceptions instead, for the editor to handle.

// literals operate on literals, and return literals...
constexpr bool operator==(const Value& a, const Value& b) const; // evaluates type, checks equality
constexpr Value+(const Literal& a, const Value& b) const;
constexpr Value[]() const;
// etc.

You can create values from primitive types

explicit Value(int value);
explicit Value(bool value);
// etc.

and convert from them

constexpr bool (bool)() const;
constexpr std::string (std::string)() const;

The editor should be responsible for ensuring the right types are used, and valid blocks and expressions are nested together.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CoreRelates to the core applicationFeatureA new addition to the project

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions