Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add coerce trait #65

Open
schwern opened this issue Feb 17, 2013 · 3 comments
Open

Add coerce trait #65

schwern opened this issue Feb 17, 2013 · 3 comments

Comments

@schwern
Copy link
Contributor

schwern commented Feb 17, 2013

Add a signature trait to turn on type coercion.

Type coercion is very useful to signatures. For example, you can coerce a path string into a Path::Class object or a URI string into a URI object. Type coercion in Moose is declared as part of the type, but the user of the type must decide to turn it on.

MooseX::Method::Signatures uses "is coerce" or "does coerce". "does" is an unfortunate choice because its normally used to declare a role. "is coerce" is grammatically awkward. "is coerced" might be better. For compatibility purposes with MXMS it may be best to accept both.

@barefootcoder
Copy link
Contributor

What I'd actually like to see is a way to do on-the-fly coercion defintions. In the same way that where allows on-demand subtyping without having to declare a subtype, I think that being able to define your coercion right in the signature would be useful.

Syntax would be open for discussion; I was just thinking of using the same from / via keywords that Moose uses for coercion definitions in the types.

@schwern
Copy link
Contributor Author

schwern commented Feb 17, 2013

We need a coercion trait regardless. Open your idea as another issue?

@barefootcoder
Copy link
Contributor

Yeah, okay, fair enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants