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 resolution document for #135 (Add Dict/Tuple to the core) #310

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 49 additions & 0 deletions solutions/language/Value-Types.md
@@ -0,0 +1,49 @@
# Basic Value Type Structures In Raku

## Preface

This resolution is based upon discussion in
[problem-solving#135](https://github.com/Raku/problem-solving/issues/135) and,
accordingly, provides a solution to the issue.

The issue was opened as a followup to unification of behaviors of `List` and
`Map` structures which resulted in both types preserving containerization of
their elements. This resulted in both types becoming non-value types,
effectively leaving Raku without value type positional and associative
structures.

## Solution

Two new types are to be added to the Raku language:

- `ValueList` to represent immutable positional value type
- `ValueMap` to represent immutable associative value type

Both types are characterized by forcible scalar de-containerization of any
object, stored in them. For example, here is how it must work with lists:

my $val = 42;
my $l := List.new($val);
say $l[0].VAR.^name; # Scalar
my $vl := ValueList.new($val);
say $vl[0].VAR.^name; # Int

It also means that for any `Value*`-type structures instances of any non-value
type classes, including but not limited to `Array` and `Hash`, are considered
the same value if they're the same object, not if their content is identical.

### Parametrization

The `Value*` types must remain non-parameterizable. Alongside with `List` and
`Map` they must provide basic functionality, sufficient to be extended with
their sub-classes in ways `Array` and `Hash` do it.

## Reasoning

Provide means for operators like `===`, types like `QuantHash`-es, and other
value-type based language entities to easily operate on positional and
associative type structures.

## Language Version Eligibility

Both types are to be available no earlier than in Raku v6.e.