Re: [csswg-drafts] `[css-nesting]` `let rec` as an idea for infix decorator-style nesting syntax (#7540)

Absolutely. [Here is a good StackOverflow starting point](https://stackoverflow.com/questions/9325888/why-does-ocaml-need-both-let-and-let-rec), and [some more, from a nice online-readable book](https://ocamlbook.org/recursive-functions/).

The basic idea is that OCaml definitions can't (at runtime) be recursive without an explicit `rec` identifier. The typical example I always see is with defining a factorial function.

```ocaml
let rec factorial n =
  if n = 0 then 1
  else n * (factorial (n-1))
```

This will function as expected (for 32- or 64-bit integer values/results, at least). However,

```ocaml
let fact n =
  if n = 0 then 1
  else n * (fact (n-1))
```

throws an error:

```
Error: Unbound value fact
Hint: If this is a recursive definition,
you should add the 'rec' keyword on line 1
```

(from `utop` on my mac).

Again, I do think the current 'optional' `@nest` is my favorite so far, I just couldn't find any discussion relating to OCaml's take on a slightly similar syntax construction and effects.

-- 
GitHub Notification of comment by harrisi
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7540#issuecomment-1196912091 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 27 July 2022 15:29:40 UTC