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

Feedback on the Moo/se to Corinna porting guide #58

Open
Ovid opened this issue Feb 21, 2022 · 18 comments
Open

Feedback on the Moo/se to Corinna porting guide #58

Ovid opened this issue Feb 21, 2022 · 18 comments

Comments

@Ovid
Copy link
Collaborator

Ovid commented Feb 21, 2022

I have an incomplete guide to porting Moo/se to Corinna: https://github.com/Ovid/Cor/wiki/Porting-from-Moose-or-Moo

Please leave feedback here.

Yes, it will eventually need to be several documents.

@Ovid Ovid changed the title Feedback on the Moo/se to Corinna Feedback on the Moo/se to Corinna porting guide Feb 21, 2022
@abraxxa
Copy link

abraxxa commented Feb 22, 2022

Can a class attribute (I hate the term 'field'!) be passed to the constructor by adding :param to its definition?

@Ovid
Copy link
Collaborator Author

Ovid commented Feb 22, 2022

@abraxxa By default, no. Constructor args are for creating an instance. You can get make this work with an alternate constructor, but generally, it's good practice—if you must use class data—to have it be immutable if classes use it. Otherwise, you can get nasty "action at a distance."

@jgamble
Copy link

jgamble commented Feb 23, 2022

I had no idea about the make_immutable method. First, thank you. Second, I had to search with a few keywords, could a direct link be provided, like to https://metacpan.org/dist/Moose/view/lib/Moose/Cookbook/Basics/Immutable.pod ?

@Ovid
Copy link
Collaborator Author

Ovid commented Feb 23, 2022

@jgamble Done! Thanks for the suggestion.

Also, there's another doc I'm not linking it in the guide because it would be a distraction, but you might find the make_immutable options to be of interest, too.

@jjn1056
Copy link

jjn1056 commented Feb 25, 2022

@Ovid maybe we could start by trying to port the Moose tutorial?

@jjn1056
Copy link

jjn1056 commented Feb 25, 2022

Since Moose doesn't do class attributes in its core feature maybe that bit should be left out. There's actually controversy on the best way to handle class attributes, maybe people don't use MooseX::ClassAttribute. I would suggest if this is a porting guide that we focus more on Moose features, how they are handled in Cor and workarounds for things the Cor doesn't do.

@jjn1056
Copy link

jjn1056 commented Feb 25, 2022

Can a class attribute (I hate the term 'field'!) be passed to the constructor by adding :param to its definition?

@abraxxa I like 'field'. I'm glad they decided to not use 'has'. That way we can write a "Cor::MooseLike" that does define a 'has' to help smooth over differences and make porting easier. I remember with Moose we created MooseX::Emulate::Class::Accessor::Fast to help speed along porting of code that used Class::Accessor, which was very popular pre Moose days.

@jjn1056
Copy link

jjn1056 commented Feb 25, 2022

We'll probably need a separate guide for handling the more common MooseX extensions. There's tons of those but a lot of them are not particularly popular. I wonder how to figure out which ones are a big deal and need to be discussed.

@abraxxa
Copy link

abraxxa commented Feb 25, 2022

Can a class attribute (I hate the term 'field'!) be passed to the constructor by adding :param to its definition?

@abraxxa I like 'field'. I'm glad they decided to not use 'has'. That way we can write a "Cor::MooseLike" that does define a 'has' to help smooth over differences and make porting easier. I remember with Moose we created MooseX::Emulate::Class::Accessor::Fast to help speed along porting of code that used Class::Accessor, which was very popular pre Moose days.

I wouldn't suggest 'has' but 'attribute', as that's what every OO coding guide and other languages calls it.

@Grinnz
Copy link

Grinnz commented Feb 25, 2022

attribute is unfortunately out of the question, because it is already a Perl feature (which Corinna itself uses).

@abraxxa
Copy link

abraxxa commented Feb 25, 2022

I don't see a keyword named 'attribute' there.

@leonerd
Copy link
Collaborator

leonerd commented Feb 25, 2022

I don't see a keyword named 'attribute' there.

class Ball :isa(Toy) :does(Roundness) { ... }

^-- :isa and :does are attributes.

field $size :reader :writer :param;

^-- as are :reader, :writer and :param

These things are all called "attributes" and have been for the past ~20 or so years that Perl has had them.

@abraxxa
Copy link

abraxxa commented Feb 25, 2022

Yes, and how does that prevent us from defining attributes using the keyword attribute?

@leonerd
Copy link
Collaborator

leonerd commented Feb 25, 2022

It would be very very confusing to have two totally-distinct concepts, both called "attributes". Especially if these object fields can have attributes themselves. How would you distinguish

attribute $name :reader :writer;

is $name an attribute here? What are :reader and :writer? Are they attributes of that attribute?

Distinct concepts must have distinct names - this is an essential part of any language; computer or otherwise.

@abraxxa
Copy link

abraxxa commented Feb 25, 2022

Those things after the double-colons don't need to be named the same as the existing sub attributes.

@Ovid
Copy link
Collaborator Author

Ovid commented Feb 26, 2022

@jjn1056 Porting the Moose tutorial actually is a great idea. I just avoided it because of time constraints. It would also be interesting because it would show the limitations of the Corinna MVP and how to work around them.

@Ovid
Copy link
Collaborator Author

Ovid commented Feb 26, 2022

@abraxxa I know where you're coming from, but we've been arguing over the color of this particular bikeshed for years. It went from has to slot to field, with many people expressing considerable relief at the latter. It's just one of those situations, like using :common for class-based behavior, that we have to work around the existing language.

@rabbiveesh
Copy link

rabbiveesh commented Feb 28, 2022 via email

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

No branches or pull requests

7 participants