On Tue, Mar 17, 2020 at 9:31 AM Rowan Tommins <rowan.coll...@gmail.com> wrote:
> Hm, I see, that does reduce the boilerplate somewhat, although it's still
> split across two classes, and probably therefore two files, which is not
> great.
As an alternative to passive associative arrays, it's a small price to pay for
splitting concerns and having a documented signature for the data structure.
Named parameters is another alternative (unfortunately outside reach for now)
that would work great for a limited number of arguments. COPA does not
make named parameters obsolete, but works great for any number of arguments.

> You're missing some code in your example, though, because you've documented
> one of the options as optional, implying the others should be mandatory; in
> which case you need something like this in the constructor:
I've rewritten parts of the RFC and some examples substantially,
and added your view of mandatory arguments in the "Open Issues" section.

> It might be interesting to have the syntax run before the constructor
> rather than after, or trigger some other magic method which could do
> tidying and validation, so it could apply to more circumstances.
Hmmm, in the Write Once Properties RFC they seem to believe
that object construction is a "fuzzy" term and that lazy initialization
is a feature.

We can add better 'automagic' support for mandatory arguments,
filtering and validation
in incremental proposals, to avoid biting off more than we can chew, but we
have to start somewhere.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to