2 questions for Sebastian

12 views
Skip to first unread message

s...@bykov.odessa.ua

unread,
Dec 26, 2011, 2:40:32 PM12/26/11
to mojol...@googlegroups.com
Hello

1) I don't understand this piece of code in Mojo/Base.pm:
63: $class = ref $class || $class;

because of it now I have to write something like this in every child package
sub setup_meta_class {
croak 'First arg must be a class name' if ref $_[0];
# ...
}
to avoid incorrect usage
may be it is better to add /croak '' if ref $class/ to Mojo::Base?

2) About my previous mail. I still think, it is better to add my patch
or maybe add
/croak '...' unless ref $_[0] eq 'HASH'/
to evaluated $code in Base.pm
Why? Because in spite of your answer, calling accessors on classes
instead of
instances is supported now, but incorrect.
And now it is easy to confuse $object->method with $class->method. So,
it is better to decide unequivocally,
does Mojo::Base support $class->accessor or not, to avoid problems in
the future

P.S.
Sorry for my English

Marty Tennison

unread,
Dec 26, 2011, 3:04:18 PM12/26/11
to mojol...@googlegroups.com
I would disagree with changing the behavior of Mojo::Base.   IMO, Mojo should assume a certain level of perl competence from the programmer.  Trying to protect programmers from bad habits should not be the job of Mojo.  Of course, everything is subjective, but I see no compelling reason to change the behaviour of Mojo::Base based on the discussion above. 

s...@bykov.odessa.ua

unread,
Dec 26, 2011, 4:03:57 PM12/26/11
to mojol...@googlegroups.com
Ok,
About point 1 of my prev mail.
I also think trying to protect programmers is a bad idea. But now Mojo do it! This row:

$class = ref $class || $class;
in attr sub decides for the programmer what to do. And the result of $blessed->attr() is not what u expect

About the point 2:
I agree, using Class->get_set is a bad idea too. But sometimes using such tech, u can get faster and more clear result (this is another discussion, i am not sure, but Roze::DB::Object is an example?)

The problem is not "does or does not Mojo::Base support it". Problem is "Mojo::Base::attr() method works incorrect sometimes, and do it quiet, withour warnings". Please, see my previous letter with "foolish" example and patch. So, i think it is necessary to use the patch and allow programmer decide what to use, or restrict using ambiguous variant.

Mojo::Base is the base module for all Mojolisious project, so it is important to discuss every possible and impossible variant of usage as soon as possible. May be I am wrong and talk nonsenses



I would disagree with changing the behavior of Mojo::Base.   IMO, Mojo should assume a certain level of perl competence from the programmer.  Trying to protect programmers from bad habits should not be the job of Mojo.  Of course, everything is subjective, but I see no compelling reason to change the behaviour of Mojo::Base based on the discussion above. 
--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mojolicious/-/HIncr61vA6wJ.
To post to this group, send email to mojol...@googlegroups.com.
To unsubscribe from this group, send email to mojolicious...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mojolicious?hl=en.

sri

unread,
Dec 26, 2011, 8:18:40 PM12/26/11
to Mojolicious
For future reference, i'll never answer a thread that has my name in
the title.
This is a community effort and we have a whole team of core
developers.

--
sebastian
Reply all
Reply to author
Forward
0 new messages