einhverfr has asked for the wisdom of the Perl Monks concerning the following question:
fellow Monks,
I have been looking at exception handling in a few projects, as well as discussing functional programming with a few Scala developers. I really like the ideal of referentially transparent errors as an output of a function. This makes it possible to reason equationally about things.
So I have thought a bit about trying to create a tied hash type, which would always evaluate as undef in a scalar context, but would have fields for error messages, inputs that are out of bounds, etc. This could be returned from a function in place of an undef as a failure value.
Where I am having some difficulties is in finding a way to apply this to my work with Moose. In particular, the question is how to apply this in lazy builders in particular. I would assume that if a value in a lazy builder does not validate, it should return the error instead of raising it as an exception.
Has anyone tried to do this before? How deep am I looking at regarding modifications?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to make Moose more "functional"?
by tobyink (Canon) on May 23, 2014 at 06:59 UTC | |
by einhverfr (Friar) on May 23, 2014 at 13:34 UTC | |
|
Re: How to make Moose more "functional"?
by Anonymous Monk on May 23, 2014 at 06:51 UTC |