http://www.perlmonks.org?node_id=963069


in reply to Introducing MooseX::hasn't

The link you posted doesn't work.
extends "Person"; hasn't name => (default => 'anon');
that reads like a contradiction. If it doesn't support the same operations as Person then in what sense does it extend Person? Or is this meant to be an Acme type module?

Replies are listed 'Best First'.
Re^2: Introducing MooseX::hasn't
by tobyink (Abbot) on Apr 02, 2012 at 22:22 UTC

    The link you posted doesn't work.

    Thanks, fixed.

    If it doesn't support the same operations as Person then in what sense does it extend Person?

    See "Doesn't this break polymorphism?" in the FAQ.

    Or is this meant to be an Acme type module?

    Initially, yes, hence the release date. But I can see potential uses for it.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
      It breaks the inheritance contract, not polymorphism per se (I think you've got the two concepts confused). Polymorphism doesn't depend on inheritance, e.g. Roles enable polymorphism without inheritance.

        No, polymorphism doesn't depend on inheritance, and I never claimed that it did. Polymorphism is generally an expected outcome of inheritance though. There are clearly other ways of allowing polymorphism though - roles as you say; also mocking, delegation, etc.

        perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'