* Moritz Lenz (mor...@faui2k3.org) [151013 07:18]:
> >In Perl5, you get slower code when you test for definedness... in Perl6
> >you get faster (better optimized) code.  That's a big difference.
> 
> Do you? Did you actually measure that?

For Perl6?  Well, Liz tells us that it can be optimized better (you
limit the range of choices)  Whether this is already the case does not
really matter here.  And at least it produces the error at the side of
the caller, not inside your function.

> >How can de invocant not be defined?
> 
> Well, if you call a constructor, you call it on the type object. Hence the
> type object is the class, and not defined.

Yes, that's the other thread which emerged from my :D question.

When you call .new, the type is well defined (maybe Any).  Trickery
links that type to some missing value "undef".  And then the programmer
is expected to understand that :U actually means "it's a class method".

I would be able to understand it better if that whole type==undef stayed
hidden from the story told to the programmer.  For instance, by calling
this flag :T (from Type)  The freed up flag :U may say "non-defined for
positional allowed", and :D can become the default.

> >There shouldn't be a problem making :D a superfluous option.  Of swiftly
> >add  "use parameters $_;"  to all modules.
> 
> Why shouldn't this be a problem?

If you make :D the default behavior, then adding "use parameters $_;"
to existing code would avoid the urgency to scan through all code to
see what needs to be changed.

> >>>   . :D looks really ugly, don't you think?  Try to explain to students
> >>>     to add this smiley everywhere.
> >>
> >>It's not uglier than a 'die "Must be defined" unless defined $x'
> >Much too expensive in Perl5.
> 
> Then don't do in Perl 6 either. If you can argue away the need for safety
> based on the need for performance, you can also argue away the need for
> safety based on the need for cleaner code.

Remember that I only ask for :D to be the default.  That's an generic
request which does not depend on my personal programming style.

For my personal Perl5 code, no: I do not check the definedness of all
parameters because it is a lot of work to code and slows-down all subs.
I have the intention to use the definedness checks on all parameters
in Perl6 because the brievety of ":D" gives me the impression that
it is fast, produces a standardized clean message, and easy to use.
So, my code would look like Tux's work: cluttered with :D

Within a code block, variables are often temporary undefined.  But as
positional parameters of functions that's rarely useful.

For named parameters, the situation is different.  In their case, you
want to choose between: "undef value means missing parameter", "undef
value means illegal value" (:D), "undef value is allowed".  For my coding
style, the first case is usually true.  I am not sure, but probably
Perl6 makes do difference between missing existence and undefinedness
of named parameters... where hashes and XML (minOccurs=0/nillable) do.
So probably merged to "undef value is allowed".

Moritz, Patrick, thanks for your patience and detailed answers!
-- 
Regards,

               MarkOv

------------------------------------------------------------------------
       Mark Overmeer MSc                                MARKOV Solutions
       m...@overmeer.net                          soluti...@overmeer.net
http://Mark.Overmeer.net                   http://solutions.overmeer.net

Reply via email to