Hi Nicolas, czw., 13 kwi 2023 o 14:40 Nicolas Grekas <nicolas.grekas+...@gmail.com> napisał(a):
> Hi Rowan, hi all! > > Le ven. 17 mars 2023 à 15:51, Larry Garfield <la...@garfieldtech.com> a > écrit : > > > On Thu, Mar 16, 2023, at 6:05 PM, Rowan Tommins wrote: > > > On 16/03/2023 22:14, Larry Garfield wrote: > > >> Wouldn't the functionality described boil down to essentially just > > materializing into a few extra lines in the constructor? At least to my > > ignorant non-engine brain it seems straightforward to have this: > > >> > > >> $a = 1; > > >> $b = 2; > > >> $c = 3; > > >> > > >> $o = new class ($a, $b) use ($c) { > > >> public function __construct(private int $a, private int $b) {} > > >> public function something() {} > > >> } > > >> > > >> Desugar to this: > > >> > > >> $c = class ($a, $b) use ($c) { > > >> private $c; > > >> public function __construct(private int $a, private int $b) { > > >> $this->c = 3; // By value only, so this should be fine? > > >> } > > >> public function something() {} > > >> } > Have you thought about not populating property by default but instead: * adding "use" language construct as default to all methods? * adding ability to assign variable values from "use" to property if needed? Like desugar to $c = class ($a, $b) use ($c) { private $c = $c; // optional, not required, no conflicts public function __construct(private int $a, private int $b) use ($c) { $this->c = $c % 2 ? 3 : 5; } public function something() use ($c) { return $c; } } Or there is something so wrong with this thinking I cannot see yet. Cheers, Michał Marcin Brzuchalski