Skip to content

Instantly share code, notes, and snippets.

@treyharris
Created April 15, 2017 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save treyharris/1de63651f545d793d17d8f221c9bdb4e to your computer and use it in GitHub Desktop.
Save treyharris/1de63651f545d793d17d8f221c9bdb4e to your computer and use it in GitHub Desktop.
Huh?
% file=irc.freenode.\#perl6.weechatlog
% grep auto-new $file
2017-04-11 15:58:14 jnthn m: multi trait_mod:<is>(Method:D $m, :$auto-new!) { $m.wrap: -> \obj, |c { callwith(obj.DEFINITE ?? obj !! obj.new, |c) } }; class C { has
$.x = 0; method m() is auto-new { say $!x } }; C.m; C.new.m
2017-04-11 15:59:09 jnthn So you only have to put "is auto-new" on the class, not on each method
2017-04-11 15:59:59 jnthn m: multi trait_mod:<is>(Method:D $m, :$auto-new!) { $m.wrap: -> \obj, |c { callwith(obj.DEFINITE ?? obj !! obj.new, |c) } }; class C { has
$.x = 0; method m() is auto-new { say $!x } }; C.m; C.new(x => 42).m # just checking :)
2017-04-11 16:00:07 TreyHarris but with that I'd write: use Whatever:from<Perl5>; class P6::Whatever is Whatever { method fields is auto-new { nextsame; } }
Binary file irc.freenode.#perl6.weechatlog matches
% pcregrep auto-new $file
2017-04-11 15:58:14 jnthn m: multi trait_mod:<is>(Method:D $m, :$auto-new!) { $m.wrap: -> \obj, |c { callwith(obj.DEFINITE ?? obj !! obj.new, |c) } }; class C { has
$.x = 0; method m() is auto-new { say $!x } }; C.m; C.new.m
2017-04-11 15:59:09 jnthn So you only have to put "is auto-new" on the class, not on each method
2017-04-11 15:59:59 jnthn m: multi trait_mod:<is>(Method:D $m, :$auto-new!) { $m.wrap: -> \obj, |c { callwith(obj.DEFINITE ?? obj !! obj.new, |c) } }; class C { has
$.x = 0; method m() is auto-new { say $!x } }; C.m; C.new(x => 42).m # just checking :)
2017-04-11 16:00:07 TreyHarris but with that I'd write: use Whatever:from<Perl5>; class P6::Whatever is Whatever { method fields is auto-new { nextsame; } }
2017-04-14 18:15:10 TreyHarris I love everything about jnthn's "auto-new" trait suggestion except the name. "method table() is auto-new" just reads wrong. But I
can't come up with a better one. "autovivified"? It's not quite the same as subscript autovivification directly translated into attribute autovivication, but it's not tha
t far off....
2017-04-14 18:28:24 AlexDaniel TreyHarris: wait, auto-new? Where can I read about it?
2017-04-14 18:30:04 jnthn (And no, I don't consider auto-new a particularly nice name either :))
2017-04-14 18:31:54 timotimo i completely missed the suggestion for this auto-new thing
% grep 'auto-new' $file
2017-04-11 15:58:14 jnthn m: multi trait_mod:<is>(Method:D $m, :$auto-new!) { $m.wrap: -> \obj, |c { callwith(obj.DEFINITE ?? obj !! obj.new, |c) } }; class C { has
$.x = 0; method m() is auto-new { say $!x } }; C.m; C.new.m
2017-04-11 15:59:09 jnthn So you only have to put "is auto-new" on the class, not on each method
2017-04-11 15:59:59 jnthn m: multi trait_mod:<is>(Method:D $m, :$auto-new!) { $m.wrap: -> \obj, |c { callwith(obj.DEFINITE ?? obj !! obj.new, |c) } }; class C { has
$.x = 0; method m() is auto-new { say $!x } }; C.m; C.new(x => 42).m # just checking :)
2017-04-11 16:00:07 TreyHarris but with that I'd write: use Whatever:from<Perl5>; class P6::Whatever is Whatever { method fields is auto-new { nextsame; } }
Binary file irc.freenode.#perl6.weechatlog matches
% grep 'auto\-new' $file
2017-04-11 15:58:14 jnthn m: multi trait_mod:<is>(Method:D $m, :$auto-new!) { $m.wrap: -> \obj, |c { callwith(obj.DEFINITE ?? obj !! obj.new, |c) } }; class C { has
$.x = 0; method m() is auto-new { say $!x } }; C.m; C.new.m
2017-04-11 15:59:09 jnthn So you only have to put "is auto-new" on the class, not on each method
2017-04-11 15:59:59 jnthn m: multi trait_mod:<is>(Method:D $m, :$auto-new!) { $m.wrap: -> \obj, |c { callwith(obj.DEFINITE ?? obj !! obj.new, |c) } }; class C { has
$.x = 0; method m() is auto-new { say $!x } }; C.m; C.new(x => 42).m # just checking :)
2017-04-11 16:00:07 TreyHarris but with that I'd write: use Whatever:from<Perl5>; class P6::Whatever is Whatever { method fields is auto-new { nextsame; } }
Binary file irc.freenode.#perl6.weechatlog matches
% egrep 'auto[-]new' $file
2017-04-11 15:58:14 jnthn m: multi trait_mod:<is>(Method:D $m, :$auto-new!) { $m.wrap: -> \obj, |c { callwith(obj.DEFINITE ?? obj !! obj.new, |c) } }; class C { has
$.x = 0; method m() is auto-new { say $!x } }; C.m; C.new.m
2017-04-11 15:59:09 jnthn So you only have to put "is auto-new" on the class, not on each method
2017-04-11 15:59:59 jnthn m: multi trait_mod:<is>(Method:D $m, :$auto-new!) { $m.wrap: -> \obj, |c { callwith(obj.DEFINITE ?? obj !! obj.new, |c) } }; class C { has
$.x = 0; method m() is auto-new { say $!x } }; C.m; C.new(x => 42).m # just checking :)
2017-04-11 16:00:07 TreyHarris but with that I'd write: use Whatever:from<Perl5>; class P6::Whatever is Whatever { method fields is auto-new { nextsame; } }
Binary file irc.freenode.#perl6.weechatlog matches
% pcregrep 'auto[-]new' $file
2017-04-11 15:58:14 jnthn m: multi trait_mod:<is>(Method:D $m, :$auto-new!) { $m.wrap: -> \obj, |c { callwith(obj.DEFINITE ?? obj !! obj.new, |c) } }; class C { has
$.x = 0; method m() is auto-new { say $!x } }; C.m; C.new.m
2017-04-11 15:59:09 jnthn So you only have to put "is auto-new" on the class, not on each method
2017-04-11 15:59:59 jnthn m: multi trait_mod:<is>(Method:D $m, :$auto-new!) { $m.wrap: -> \obj, |c { callwith(obj.DEFINITE ?? obj !! obj.new, |c) } }; class C { has
$.x = 0; method m() is auto-new { say $!x } }; C.m; C.new(x => 42).m # just checking :)
2017-04-11 16:00:07 TreyHarris but with that I'd write: use Whatever:from<Perl5>; class P6::Whatever is Whatever { method fields is auto-new { nextsame; } }
2017-04-14 18:15:10 TreyHarris I love everything about jnthn's "auto-new" trait suggestion except the name. "method table() is auto-new" just reads wrong. But I
can't come up with a better one. "autovivified"? It's not quite the same as subscript autovivification directly translated into attribute autovivication, but it's not tha
t far off....
2017-04-14 18:28:24 AlexDaniel TreyHarris: wait, auto-new? Where can I read about it?
2017-04-14 18:30:04 jnthn (And no, I don't consider auto-new a particularly nice name either :))
2017-04-14 18:31:54 timotimo i completely missed the suggestion for this auto-new thing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment