in reply to Re^2: Idea: Moose Mutal Coercion
in thread Idea: Moose Mutual Coercion

This is no criticism of the goals of your module.

But ... you knew it was coming right? ... Do you have a more realistic example of how and why it might be used?

The problem with using a toy example to illustrate the functionality, is that it ends up looking like a solution looking for a problem.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

Replies are listed 'Best First'.
Re^4: Idea: Moose Mutal Coercion
by educated_foo (Vicar) on Feb 15, 2012 at 13:58 UTC
    A less-distracting example might be a ball with mass, velocity, and momentum (calculate the third given two). I still think reaching for a lazy-building pile of Moose goop is wrong, since it's way easier to just have a cache:
    sub momentum { my $self = shift; $self->{momentum} //= $self->{mass} * $self->{velocity}; }
    but at least this may let people focus on the idea.

      You think that the OP is suggesting that Moose herders use his module so that they can type this:

      package Equation_Problem; use Moose; use MooseX::Invertible_Build; has mass => ( isa => Num); has velocity => ( isa => Num); has momentum => ( isa => Num, invertible_build => { A => 'mass', B => 'velocity', via => 'A * B', }, );

      To 'save' typing:

      package Equation_Problem; use Moose; has mass => ( isa => Num); has velocity => ( isa => Num); sub momentum { my $self = shift; $self->mass * $self->velocity; }

      Hm. It can't be that in(s)ane.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?

        No. I guess the OP wants a class which you can initialize with any two attributes, but you can then ask for all three.