mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 07:41:12 +00:00
Rename Func to CallByName
This commit is contained in:
parent
41ddfc149b
commit
c85f246988
5 changed files with 19 additions and 19 deletions
|
@ -32,7 +32,7 @@ For example, parsing will transalte this string:
|
||||||
|
|
||||||
...into this `Expr`:
|
...into this `Expr`:
|
||||||
|
|
||||||
Func("not", vec!["foo", "bar"])
|
CallByName("not", vec!["foo", "bar"])
|
||||||
|
|
||||||
Now we may know that `not` takes a `Bool` and returns another `Bool`, but the parser doesn't know that.
|
Now we may know that `not` takes a `Bool` and returns another `Bool`, but the parser doesn't know that.
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ pub fn scoped_eval(expr: Expr, vars: &Scope) -> Evaluated {
|
||||||
scoped_eval(*in_expr, vars)
|
scoped_eval(*in_expr, vars)
|
||||||
},
|
},
|
||||||
|
|
||||||
Func(name, args) => {
|
CallByName(name, args) => {
|
||||||
let func_expr = match vars.get(&name) {
|
let func_expr = match vars.get(&name) {
|
||||||
Some(resolved) => {
|
Some(resolved) => {
|
||||||
let Evaluated(ref evaluated_expr) = **resolved;
|
let Evaluated(ref evaluated_expr) = **resolved;
|
||||||
|
|
|
@ -16,7 +16,7 @@ pub enum Expr {
|
||||||
Assign(Pattern, Box<Expr>, Box<Expr>),
|
Assign(Pattern, Box<Expr>, Box<Expr>),
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
Func(Ident, Vec<Expr>),
|
CallByName(Ident, Vec<Expr>),
|
||||||
Apply(Box<Expr>, Vec<Expr>),
|
Apply(Box<Expr>, Vec<Expr>),
|
||||||
Operator(Box<Expr>, Operator, Box<Expr>),
|
Operator(Box<Expr>, Operator, Box<Expr>),
|
||||||
Closure(SmallVec<[Pattern; 2]>, Box<Expr>),
|
Closure(SmallVec<[Pattern; 2]>, Box<Expr>),
|
||||||
|
|
|
@ -352,7 +352,7 @@ where I: Stream<Item = char, Position = IndentablePosition>,
|
||||||
// allocating a Vec in the common case where this is a var
|
// allocating a Vec in the common case where this is a var
|
||||||
match opt_args {
|
match opt_args {
|
||||||
None => Expr::Var(name),
|
None => Expr::Var(name),
|
||||||
Some(args) => Expr::Func(name, args)
|
Some(args) => Expr::CallByName(name, args)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -404,14 +404,14 @@ mod test_parse {
|
||||||
|
|
||||||
expect_parsed_apply(
|
expect_parsed_apply(
|
||||||
"(x 5) y",
|
"(x 5) y",
|
||||||
Func("x".to_string(), vec![Int(5)]),
|
CallByName("x".to_string(), vec![Int(5)]),
|
||||||
Var("y".to_string())
|
Var("y".to_string())
|
||||||
);
|
);
|
||||||
|
|
||||||
expect_parsed_apply(
|
expect_parsed_apply(
|
||||||
"(x 5) (y 6)",
|
"(x 5) (y 6)",
|
||||||
Func("x".to_string(), vec![Int(5)]),
|
CallByName("x".to_string(), vec![Int(5)]),
|
||||||
Func("y".to_string(), vec![Int(6)]),
|
CallByName("y".to_string(), vec![Int(6)]),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect_parsed_apply(
|
expect_parsed_apply(
|
||||||
|
@ -435,7 +435,7 @@ mod test_parse {
|
||||||
|
|
||||||
fn expect_parsed_func<'a>(parse_str: &'a str, func_str: &'a str, args: Vec<Expr>) {
|
fn expect_parsed_func<'a>(parse_str: &'a str, func_str: &'a str, args: Vec<Expr>) {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Ok((Func(func_str.to_string(), args), "")),
|
Ok((CallByName(func_str.to_string(), args), "")),
|
||||||
parse_standalone(parse_str)
|
parse_standalone(parse_str)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -484,7 +484,7 @@ mod test_parse {
|
||||||
(
|
(
|
||||||
Operator(
|
Operator(
|
||||||
Box::new(
|
Box::new(
|
||||||
Func("f".to_string(),
|
CallByName("f".to_string(),
|
||||||
vec![Int(5)],
|
vec![Int(5)],
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
@ -504,7 +504,7 @@ mod test_parse {
|
||||||
(
|
(
|
||||||
Operator(
|
Operator(
|
||||||
Box::new(
|
Box::new(
|
||||||
Func("f".to_string(),
|
CallByName("f".to_string(),
|
||||||
vec![Int(1), Int(2), Int(3)],
|
vec![Int(1), Int(2), Int(3)],
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
@ -638,8 +638,8 @@ mod test_parse {
|
||||||
Case(
|
Case(
|
||||||
Box::new(Int(0)),
|
Box::new(Int(0)),
|
||||||
smallvec![
|
smallvec![
|
||||||
( Integer(2), Box::new(Func("foo".to_string(), vec![Int(9)])) ),
|
( Integer(2), Box::new(CallByName("foo".to_string(), vec![Int(9)])) ),
|
||||||
( Integer(1), Box::new(Func("bar".to_string(), vec![Int(8)])) ),
|
( Integer(1), Box::new(CallByName("bar".to_string(), vec![Int(8)])) ),
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
""
|
""
|
||||||
|
@ -784,18 +784,18 @@ mod test_parse {
|
||||||
fn complex_expressions() {
|
fn complex_expressions() {
|
||||||
expect_parsed_apply(
|
expect_parsed_apply(
|
||||||
"(x 5) (y + (f 6))",
|
"(x 5) (y + (f 6))",
|
||||||
Func("x".to_string(), vec![Int(5)]),
|
CallByName("x".to_string(), vec![Int(5)]),
|
||||||
Operator(
|
Operator(
|
||||||
Box::new(Var("y".to_string())),
|
Box::new(Var("y".to_string())),
|
||||||
Plus,
|
Plus,
|
||||||
Box::new(Func("f".to_string(), vec![Int(6)])),
|
Box::new(CallByName("f".to_string(), vec![Int(6)])),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_standalone("(x 5)"),
|
parse_standalone("(x 5)"),
|
||||||
Ok((
|
Ok((
|
||||||
Func("x".to_string(), vec![Int(5)]),
|
CallByName("x".to_string(), vec![Int(5)]),
|
||||||
"")
|
"")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -856,7 +856,7 @@ mod test_parse {
|
||||||
parse_standalone("(x 5) + 123"),
|
parse_standalone("(x 5) + 123"),
|
||||||
Ok((
|
Ok((
|
||||||
Operator(
|
Operator(
|
||||||
Box::new(Func("x".to_string(), vec![Int(5)])),
|
Box::new(CallByName("x".to_string(), vec![Int(5)])),
|
||||||
Plus,
|
Plus,
|
||||||
Box::new(Int(123))
|
Box::new(Int(123))
|
||||||
),
|
),
|
||||||
|
@ -868,7 +868,7 @@ mod test_parse {
|
||||||
parse_standalone("(x 5) + (2 * y)"),
|
parse_standalone("(x 5) + (2 * y)"),
|
||||||
Ok((
|
Ok((
|
||||||
Operator(
|
Operator(
|
||||||
Box::new(Func("x".to_string(), vec![Int(5)])),
|
Box::new(CallByName("x".to_string(), vec![Int(5)])),
|
||||||
Plus,
|
Plus,
|
||||||
Box::new(
|
Box::new(
|
||||||
Operator(
|
Operator(
|
||||||
|
@ -894,7 +894,7 @@ mod test_parse {
|
||||||
Identifier(
|
Identifier(
|
||||||
"abc".to_string()
|
"abc".to_string()
|
||||||
),
|
),
|
||||||
Box::new(Func(
|
Box::new(CallByName(
|
||||||
"y".to_string(),
|
"y".to_string(),
|
||||||
vec![
|
vec![
|
||||||
Int(
|
Int(
|
||||||
|
@ -1046,7 +1046,7 @@ mod test_parse {
|
||||||
Identifier("f".to_string()),
|
Identifier("f".to_string()),
|
||||||
Box::new(Closure(
|
Box::new(Closure(
|
||||||
smallvec![Identifier("x".to_string())],
|
smallvec![Identifier("x".to_string())],
|
||||||
Box::new(Func("c".to_string(), vec![Int(1)]))
|
Box::new(CallByName("c".to_string(), vec![Int(1)]))
|
||||||
)),
|
)),
|
||||||
Box::new(Var("f".to_string()))
|
Box::new(Var("f".to_string()))
|
||||||
),
|
),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue