You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
my $average_score :of(WholeNum) = compute_average_score();
it would be nice to be able to tell immediately whether WholeNum is a check or a coercion, without having to look it up. This could, for example, help me understand whether some strange behaviour I'm seeing must be the fault of compute_average_score or if the coercion could be involved.
Why not use different attributes for checks and coercions? E.g.
my $average_score :of(PositiveInteger) :via(RoundToInteger) = ...;
I see two advantages:
Someone reading the code can immediately tell whether something's a check or a coercion.
Checks and coercions can be cleanly combined: just use both attributes.
Is there any disadvantage?
Just a casual perl user here; read the spec and thought it looks quite nice except for this. I don't have experience with large perl codebases so treat this suggestion appropriately :)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
If I'm debugging someone's code and see:
it would be nice to be able to tell immediately whether
WholeNum
is a check or a coercion, without having to look it up. This could, for example, help me understand whether some strange behaviour I'm seeing must be the fault ofcompute_average_score
or if the coercion could be involved.Why not use different attributes for checks and coercions? E.g.
I see two advantages:
Is there any disadvantage?
Just a casual perl user here; read the spec and thought it looks quite nice except for this. I don't have experience with large perl codebases so treat this suggestion appropriately :)
Beta Was this translation helpful? Give feedback.
All reactions