has Num $.mm is rw = 0;
yield $inch = $.mm * 25.4;
self.mm = $inch / 25.4;
Would you regard that as elegant?
That looks functionally incorrect to my eyes: if the caller resumes at
the time of the "yield" statement, and immediately assigns a new value
to the "mm" attribute, then there is a race between the two updates to
Why two assignments? [cut]
The sequence I was thing of is:
my $obj = Length.new;
$obj.mm = 42;
say $obj.inch; # your "Length.inch" method yields
$obj.mm = 63;
say $obj.inch; # Length.inch to resumes, overwriting $obj.mm back to 42
It seems to me that the assignment within your "inch" method will occur
*after* my assignment of "$obj.mm = 63"