Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: (Solved?) Moose type-constraint is unhappy with defaults ... why?

by phaylon (Curate)
on Nov 24, 2011 at 17:34 UTC ( #939923=note: print w/replies, xml ) Need Help??


in reply to (Solved?) Moose type-constraint is unhappy with defaults ... why?

The main reason for MooseX-Types at the time was that since Moose types are global, you have to be careful about conflicts. Your "MyOffset" type for example is not very distinct. Another module could easily have that type itself. So it became best practice to name them "MyProject::MyType" with a project prefix.

So MooseX-Types is there to do the following for you:

  • Encapsulate your types into a reusable library from which you can import the types into your current package.
  • Provide the types as exported functions so typos can be caught.
  • Handle namespacing of the types so they don't conflict.

The last part is crucial here. Since the declared types are namespaced, your type is actually named "myTypes::myOffset". If you use the bareword you don't have to type out the namespace, among other things.

So basically what zwon++ said is right, just wanted to give some context as to the reasons of why it is this way.


Ordinary morality is for ordinary people. -- Aleister Crowley
  • Comment on Re: (Solved?) Moose type-constraint is unhappy with defaults ... why?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://939923]
help
Chatterbox?
[stevieb]: ahem... s/no idea how to use it/didn't read enough as to what it's used for/
[stevieb]: interestingly enough, someone else got my Devel::Examine:: Subs distribution for their PRC, and I applaud the change. This dist is extremely complicated and mostly obfu, but the person doing it understood PPI enough to change...
[stevieb]: ...something I had overlooked in the extreme depths of the core functionality. After merging, then a couple of extra tweaks, I still have 100% test coverage. Yay for people who write tests!

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2017-01-24 01:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (199 votes). Check out past polls.