1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use r_derive::*;

use crate::callable::core::*;
use crate::formals;
use crate::lang::*;
use crate::object::*;

/// Construct a `list`
///
/// A central data structure constructor for a `list`, a heterogeneous
/// collection of objects. A `list` may have names, corresponding
/// to each element. Constructed using `list()`, or the syntactic
/// shorthand, `(,)`.
///
/// # In-Language
///
/// ## Usage
///
/// ```custom,{class=r}
/// list(...)
/// (...,)
/// ```
///
/// ## Arguments
///
/// `...`: Arguments to collect into a `list`.
///
/// ## Differences to the R implementation
///
/// Setting a list value to `null` does not remove the element but
/// sets it to the value `null`.
///
/// ## Examples
///
/// ```custom,{class=r-repl}
/// list(one = 1, two = "two", three = 3.0)
/// ```
///
/// or using the syntactic sugar, `( ,)`
///
/// ```custom,{class=r-repl}
/// (1, "two", 3.0)
/// ```
///
/// To construct a `list` with only one element, a trailing comma is
/// required to disambiguate it from parentheses used for establishing
/// an order of operations.
///
/// ```custom,{class=r-repl}
/// (1,)
/// ```
#[doc(alias = "list")]
#[builtin(sym = "list")]
#[derive(Debug, Clone, PartialEq)]
pub struct PrimitiveList;

formals!(PrimitiveList, "(...)");

impl Callable for PrimitiveList {
    fn call(&self, args: ExprList, stack: &mut CallStack) -> EvalResult {
        stack.eval_list_eager(args)
    }

    fn call_assign(&self, _value: Expr, _args: ExprList, _stack: &mut CallStack) -> EvalResult {
        // unpacking here!
        todo!();
    }
}