rfc:closure_self_reference
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:closure_self_reference [2023/06/03 18:37] – danack | rfc:closure_self_reference [2023/06/03 21:01] (current) – Typo danack | ||
---|---|---|---|
Line 2: | Line 2: | ||
* Version: 1.0 | * Version: 1.0 | ||
* Date: 2023-06-03 | * Date: 2023-06-03 | ||
- | * Author: Danack | + | * Author: Danack, KapitanOczywisty |
- | * Status: | + | * Status: |
* First Published at: https:// | * First Published at: https:// | ||
Line 54: | Line 54: | ||
===== Syntax choices ===== | ===== Syntax choices ===== | ||
- | There are a plethora of possible syntax choices. Those that have been though | + | There are a plethora of possible syntax choices. Those that have been thought |
==== A constant ==== | ==== A constant ==== | ||
Line 105: | Line 105: | ||
<code php> | <code php> | ||
- | $fibonacci = function $fn(int $n) as $fn { | + | $fibonacci = function $fn(int $n) { |
if ($n === 0) return 0; | if ($n === 0) return 0; | ||
if ($n === 1) return 1; | if ($n === 1) return 1; | ||
Line 111: | Line 111: | ||
}; | }; | ||
- | $factorial = fn $fn(int $num) as $fn : int => $num > 1 ? $num * $fn($num - 1) : $num; | + | $factorial = fn $fn(int $num): int => $num > 1 ? $num * $fn($num - 1) : $num; |
</ | </ | ||
Line 128: | Line 128: | ||
<code php> | <code php> | ||
- | $factorial = fn(int $num) as $fn: int => $num > 1 ? $num * $fn($num - 1) : $num; | + | $factorial = fn(int $num): int => $num > 1 ? $num * $fn($num - 1) : $num; |
</ | </ | ||
Line 147: | Line 147: | ||
- | ===== Syntax choice ===== | + | ===== Syntax choice |
- | The following syntaxes are excluded for the reasons listed: | + | Of the syntaxes considered, the following syntaxes are excluded for the reasons listed: |
* A constant. Although this could work it has multiple aesthetic downsides of being verbose, ugly, and just not very language-y. | * A constant. Although this could work it has multiple aesthetic downsides of being verbose, ugly, and just not very language-y. |
rfc/closure_self_reference.1685817420.txt.gz · Last modified: 2023/06/03 18:37 by danack