# New Ticket Created by  Rob Hoelz 
# Please include the string:  [perl #126680]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=126680 >


Excerpt from #perl6:

    22:42       hoelzro         if the default logic happens after BUILD, then 
$!server is Str because BUILD doesn't set it up via its signature
    22:43               m: class Person { has $.name = 'John'; has $.age = 21; 
submethod BUILD(:$!name) { say $!age } }; say Person.new(:name<Rob>)
    22:43       camelia         rakudo-moar d410e3: 
OUTPUT«(Any)␤Person.new(name => "Rob", age => Any)␤»
    ...
    22:43       hoelzro         m: class Person { has $.name = 'John'; has 
$.age = 21; submethod BUILD() { say $!age } }; say Person.new(:name<Rob>)
    22:43       camelia         rakudo-moar d410e3: 
OUTPUT«(Any)␤Person.new(name => "John", age => Any)␤»
    ...
    22:43       Juerd   Right, but that would mean that I can't use any of the 
defaulting logic if I want other stuff to happen at initialization, using those 
defaults...
    22:43       hoelzro         hmm...that's interesting
    22:43               m: class Person { has $.name = 'John'; has $.age = 21; 
submethod BUILD() {  } }; say Person.new(:name<Rob>)
    22:43       camelia         rakudo-moar d410e3: OUTPUT«Person.new(name => 
"John", age => 21)␤»
    22:43       Juerd   I can only imagine that this is an extremely common use 
case.
    ...
    22:44       hoelzro         it looks like referring to any attributes in 
BUILD circumvents their defaulting logic, which seems...odd.
    ...
    22:44       Juerd   I could just add the defaults to BUILD's signature, but 
it's so nice to have them all in one place :(
    22:44       hoelzro         Juerd: I think that's a rakudobug

Reply via email to