On 2024-02-12 17:45, Ovid wrote:
> [...]
> The only caveat is I realize the team never came to an agreement about
> what the :writer would return. Some insist upon the invocant (chaining
> mutators) while others want void. Returning a true value or previous
> value were minority opinions.
>
Some general remarks:
Chaining is mostly only good for configuration and setup contexts.
You generally start out with a copy of a default configuration, as an
object, and then specialize it.
Once specialized enough, you call something like $task->run, to put the
configuration to use, to solidify it, to finish it.
For returning a previous value, explicitly use a get_set method, that
itself explicitly calls get and then set, as then both get and set can
be overridden.
Any writer should return some (established or promised) final state in
some way, either inside the underlying (log-)object, or directly. Avoid
global variables.
-- Ruud
Random chaining example:
my $sql= SQL -> from(t1 => "X") -> join(t2 => "Y", -on => {"t2.[%
t1.name_lc %]_id" => "t1.id"}) -> where(...) -> select(...) ->
group_by(...) -> having(...) -> order_by(...);
my $rv= $sql -> prepare(...);
if ($rv->err) {
...;
}
else {
$rv= $sql -> execute;
}
> [...]
> The only caveat is I realize the team never came to an agreement about
> what the :writer would return. Some insist upon the invocant (chaining
> mutators) while others want void. Returning a true value or previous
> value were minority opinions.
>
Some general remarks:
Chaining is mostly only good for configuration and setup contexts.
You generally start out with a copy of a default configuration, as an
object, and then specialize it.
Once specialized enough, you call something like $task->run, to put the
configuration to use, to solidify it, to finish it.
For returning a previous value, explicitly use a get_set method, that
itself explicitly calls get and then set, as then both get and set can
be overridden.
Any writer should return some (established or promised) final state in
some way, either inside the underlying (log-)object, or directly. Avoid
global variables.
-- Ruud
Random chaining example:
my $sql= SQL -> from(t1 => "X") -> join(t2 => "Y", -on => {"t2.[%
t1.name_lc %]_id" => "t1.id"}) -> where(...) -> select(...) ->
group_by(...) -> having(...) -> order_by(...);
my $rv= $sql -> prepare(...);
if ($rv->err) {
...;
}
else {
$rv= $sql -> execute;
}