This commit is contained in:
Pierre-Emmanuel Wulfman 2020-03-11 11:18:39 +01:00
parent abbc20459c
commit dbb6fbd8e6
4 changed files with 7 additions and 7 deletions

View File

@ -301,13 +301,13 @@ gitlab-pages/docs/language-basics/src/functions/incr_map.religo incr_map
## Recursive function ## Recursive function
LIGO function are not recursive by default, the user need to indicate that the function is recursive. LIGO functions are not recursive by default, the user need to indicate that the function is recursive.
At the moment, recursive function are limited to one (possibly tupled) parameter and recursion is At the moment, recursive function are limited to one (possibly tupled) parameter and recursion is
limited to tail recursion (i.e the recursive call should be the last expression of the function) limited to tail recursion (i.e the recursive call should be the last expression of the function)
<Syntax syntax="pascaligo"> <Syntax syntax="pascaligo">
In PascaLigo recursive funciton are defined using the "recursive" keyword In PascaLigo recursive functions are defined using the "recursive" keyword
```pascaligo group=d ```pascaligo group=d
recursive function sum (const n : int; const acc: int) : int is recursive function sum (const n : int; const acc: int) : int is
@ -318,7 +318,7 @@ recursive function fibo (const n: int; const n_1: int; const n_0 :int) : int is
``` ```
</Syntax> </Syntax>
<Syntax syntax="cameligo"> <Syntax syntax="cameligo">
In CameLigo recursive funciton are defined using the "rec" keyword In CameLigo recursive functions are defined using the "rec" keyword
```cameligo group=d ```cameligo group=d
let rec sum ((n,acc):int * int) : int = let rec sum ((n,acc):int * int) : int =
@ -329,7 +329,7 @@ let rec fibo ((n,n_1,n_0):int*int*int) : int =
``` ```
</Syntax> </Syntax>
<Syntax syntax="reasonligo"> <Syntax syntax="reasonligo">
In ReasonLigo recursive funciton are defined using the "rec" keyword In ReasonLigo recursive functions are defined using the "rec" keyword
```reasonligo group=d ```reasonligo group=d
let rec sum = ((n, acc) : (int,int)): int => let rec sum = ((n, acc) : (int,int)): int =>

View File

@ -203,7 +203,7 @@ field_decl:
and value = {field_name=$1; colon=$2; field_type=$3} and value = {field_name=$1; colon=$2; field_type=$3}
in {region; value} } in {region; value} }
(* Top-level non-eecursive definitions *) (* Top-level definitions *)
let_declaration: let_declaration:
"let" ioption("rec") let_binding seq(Attr) { "let" ioption("rec") let_binding seq(Attr) {

View File

@ -261,7 +261,7 @@ field_decl:
and value = {field_name=$1; colon=$2; field_type=$3} and value = {field_name=$1; colon=$2; field_type=$3}
in {region; value} } in {region; value} }
(* Top-level non-recursive definitions *) (* Top-level definitions *)
let_declaration: let_declaration:
seq(Attr) "let" ioption("rec") let_binding { seq(Attr) "let" ioption("rec") let_binding {

View File

@ -73,7 +73,7 @@ module Errors = struct
let untyped_recursive_function var = let untyped_recursive_function var =
let title () = "" in let title () = "" in
let message () = let message () =
Format.asprintf "\nUntyped recursive function \ Format.asprintf "\nUntyped recursive functions \
are not supported yet.\n" in are not supported yet.\n" in
let param_loc = var.Region.region in let param_loc = var.Region.region in
let data = [ let data = [