»ö« Welcome to Perl 6! | perl6.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: irc.perl6.org or colabti.org/irclogger/irclogger_log/perl6 | UTF-8 is our friend! 🦋
Set by Zoffix on 25 July 2018.
antoniogamiz good morning o/ 07:29
jmerelo antoniogamiz: hey! 07:35
masak morning, #perl6 07:37
antoniogamiz well, after some time traveling from issue to issue, I think I've more or less complete my proposal :) 09:18
the first sketch at least \o/
anyone insterested in the doc system can check it out here: github.com/antoniogamiz/perl6-gsoc-application 09:19
antoniogamiz tbrowder: I'm very insterested in your feedback about it, when you have some free time please tell me :) 09:19
xinming_ 'does' will make object does the role, 'but' will make a new object and apply that role. Is there a good way to memorize this? Since I'm always confused about does-vs-but 09:39
I always need to check up the doc to confirm, which makes me think I need to find a better way to remmeber this. 09:40
xinming_ I just now get the idea, the does will do 'does' to class, which modifies the class itself, which is same as %var does ... 09:51
then, but is the other way.
moritz xinming_: "but does the same as does, *but* it also clones first" 09:53
moritz that's my mnemonic for it 09:53
xinming_ Ok, both works. :-) 10:02
m: my @history = <c d e f>; @history[* - 1, * - 2].perl.say; Is there a shortcut for * - 1, * - 2 in this case? 10:04
camelia 5===SORRY!5=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> 3 Is there a shortcut for * - 1, * - 27⏏5 in this case?
expecting any of:
infix
infix stopper
xinming_ m: my @history = <c d e f>; @history[* - 1, * - 2].perl.say; # Is there a shortcut for * - 1, * - 2 in this case?
camelia ("f", "e")
tbrowder antoniogamiz: that is looking good to me. good idea to use a mini-docs. just make sure of complete doc tree coverage. the issue of pod parsing without execution is also a big seller. 10:35
tbrowder SmokeMachine: i am not making progress. i can't keep working on red while the real-world case needs more immediate attention. this evening i plan to change the case into 3 parts: (1) the background, data and problem description and data modeling, (2) the crud description and implemention using curt tilmes' DBD::SQLite, and (3) the 10:48
crud solution with red.
SmokeMachine tbrowder: what's the problem you are having? 10:51
antoniogamiz tbrowder: thanks for your opinion :) 10:52
tbrowder it seems to be the relationships. i went back and tried to lay out the tables for sql as accurately as i can. then i tried to translate that to red using your suggestions as a guide. but i cannot successfully create a new person.attends entry. i cannot update thr PR until this evening, but i will push the current state then. 10:56
antoniogamiz: you are welcome
SmokeMachine: given my lack of rdbms experience, the whole problem may be in my basic layout of the tables. at least with my new plan i can understand modeling errors better before i introduce an orm approach. 11:01
tbrowder with red and its deep ast approach, maybe it could eventually do step 3 from the user's sql (which is almost there now i know). 11:03
SmokeMachine tbrowder: the problem seems to be a Red bug... :( 11:22
tbrowder ok, sorry, but that makes me feel a bit better :) 11:24
easily fixable?
SmokeMachine tbrowder: I hope so... 11:29
tbrowder: is this what you are having?
www.irccloud.com/pastebin/StJaMxpJ/
tbrowder: that's not a fix (Ill still fix it) but probably if you change the name of the column `first` it will work... 11:33
tbrowder: ^^
SmokeMachine tbrowder: fixed! github.com/FCO/Red/commit/2a4d4e5d...70d84fb0fc 11:48
SmokeMachine tbrowder: thank you for your help! 11:54
tbrowder SmokeMachine: that error looks familiar! i’ll check yr fix tis evening, thanks! 12:33
titsuki bisectable: class A { has @.a; submethod BUILD(:@!a) {} }; class B { has @.b; submethod BUILD(:@!b) {} }; class C is A is B { method plot { say @.a; say @.b; } }; C.new(:b([1,2,3])).plot 13:00
bisectable6 titsuki, Bisecting by output (old=2015.12 new=787d5bf) because on both starting points the exit code is 0
titsuki, bisect log: gist.github.com/94b94708e110ee633a...c2c33dc22e
titsuki, (2017-10-07) github.com/rakudo/rakudo/commit/16...81067d3f8c
xinming_ my (%last, %prev) := @history[* - 1, * - 2]; <--- Is use of := operator valid in this case? 14:04
Imean binding both %last and %prev
moritz m: my @h = {:1a}, {:2a}; my (%l, %p) := @h; say %p 14:12
camelia {a => 2}
moritz seems it should work
xinming_ Is the binding affects the var inside the declaration? 14:27
I hope so.
xinming_ m: my @h = %({}); @h.perl.say; 14:28
camelia [] 14:28
xinming_ Why is this example won't create an empty hash inside the array?
m: my @h = %({}),; @h.perl.say; 14:29
camelia [{},]
xinming_ This version worked.
binding works for var declared 14:30
which is really nice. :-)
timotimo it's the "single argument rule" that causes the assignment to iterate the "outermost" iterable, which is the hash itself 14:31
yoleaux 02:59Z <MasterDuke> timotimo: if you check the logs here colabti.org/irclogger/irclogger_lo...9-03-22#l5 you'll see some discussion i had with ugexe about weird profile/spesh log results. you might have some comment
tony-o notable6: libcsv module github.com/tony-o/perl6-libcsv 15:29
notable6 tony-o, Noted!
lizmat tony-o: is there any reason you're not uploading to CPAN ? 15:56
kawaii Probably for the same reasons my modules aren't on CPAN, it's antiquated compared to just doing releases on github 16:19
SmokeMachine m: class Bla:api<42> {}; class Ble:ble<42> {} # shouldn't it say 'ver', 'auth' and 'api'? 16:25
camelia 5===SORRY!5=== Error while compiling <tmp>
Cannot use adverb ble on a type name (only 'ver' and 'auth' are understood)
at <tmp>:1
------> 3class Bla:api<42> {}; class Ble:ble<42>7⏏5 {} # shouldn't it say 'ver', 'auth' and
expecti…
lizmat SmokeMachine: good catch 16:27
will fix
SmokeMachine :) 16:28
I think it should be a way to add possible adverbs to your class... 16:30
possible custom adverbs...
lizmat updated, but Geth appears to be AWOL 16:30
cpan-p6 New module released to CPAN! XML-XPath (0.9.3) by 03UFOBAT 16:32
tony-o lizmat: i don't have a cpan id 16:34
ugexe what is the use case for custom adverbs instead of using attributes?
lizmat tony-o: pause.perl.org/pause/query?ACTION=request_id :-) 16:35
ugexe tony-o: arent you metacpan.org/author/YNOTO ? 16:36
lizmat :-) 16:37
SmokeMachine ugexe: migration Bla:from<0.1>:to<0.2> { ... }
ugexe i do stuff like that via `role META[$version where * == 1] { }; role META[$version where * == 2] { }; META[...].new(...)` 16:38
SmokeMachine ugexe: but now Im thinking of: migration Bla:ver<0.2> { method from(v0.1) { ... } }
tony-o ah, i suppose..i don't recall getting an email about that going through 16:39
jmerelo ugexe: could that be a possible solution to this? stackoverflow.com/questions/552652...ed-subsets A bunch of roles would have to be defined, though... 16:40
SmokeMachine: you want Dockerfile phased building in Perl 6 syntax...
tony-o jmerelo: libyaml should build now, something weird happening in those makefiles with Build.pm/LibraryMake 16:41
SmokeMachine jmerelo: no, this: github.com/FCO/Red/issues/15 16:43
jmerelo tony-o: I'll try to check it out. Thanks for telling me.
jmerelo SmokeMachine: I wouldn't complicate syntax more that it is now. You can simply keep using whatever you want to use from previous versions, and use IS DEPRECATED for whatever you want to stop using. 16:44
SmokeMachine jmerelo: you think Red shouldn't make it easy to transform and move data from old version of a model to a new one? 16:47
jmerelo SmokeMachine: OK, I see what you mean. But you are using the metamodel to do that kind of things. Why don't you add an attribute via metamodel? 16:54
SmokeMachine jmerelo: what do you mean? 16:55
jmerelo SmokeMachine: I'm not sure. I guess you don't want to use class attributes because they are reserved to the actual things stored in the database, but you could use something like class.^ver and class.^from to migrate 16:56
lizmat tony-o: mail to YNOTO is bounced with <<< 554 5.7.1 [email@hidden.address] Recipient address rejected: Access denied 16:57
SmokeMachine jmerelo: that's what Im doing here: github.com/FCO/Red/issues/15#issue...-475078080 17:04
jmerelo SmokeMachine: great :-) 17:05
SmokeMachine but this way can't handle some changes, as written here: github.com/FCO/Red/issues/15#issue...-475564988
jmerelo: ^^
jmerelo: so Im thinking of using the type Migration for encapsulate the models and the changes (as suggested by Xliff) 17:06
jmerelo: Im trying to see what would be the best way to do that... 17:07
jmerelo SmokeMachine: good luck! :-)
SmokeMachine jmerelo: `migration:from<1>:to<2>` is one way I thought be good... but that's not possible...
jmerelo: and I think it should be possible... :( (even if I don't use it...) 17:08
ugexe you'll never have 2 "Migration" types of different from/to in the same lexical scope at once? 17:09
you cant `use Foo:ver<1>; use Foo:ver<2>;` for instance -- its `{ use Foo:ver<1> }; { use Foo:ver<2> }`
ugexe m: class Foo:ver<1> { }; class Foo:ver<2> { }; 17:10
camelia 5===SORRY!5=== Error while compiling <tmp>
Redeclaration of symbol 'Foo'
at <tmp>:1
------> 3class Foo:ver<1> { }; class Foo:ver<2>7⏏5 { };
expecting any of:
generic role
SmokeMachine ugexe: yes, I know... I’m not sure yet what I should do for it... 17:16
ugexe you have two pieces of logic. $from for ultimately creating logic for *reading* the current format, and $to for ultimately creating logic for the output format. $to and $from don't need to be coupled 17:19
no one wants to create a migration for from=1 to=3 *AND* from=2 to=3 17:20
if you want to couple them then there is no need for from= at all, since it should always be $to - 1 17:22
and you apply each migration in sequence 17:23
vrurg m: my Int $a; say $a > 0 17:35
camelia Invocant of method 'Bridge' must be an object instance of type 'Int', not a type object of type 'Int'. Did you forget a '.new'?
in block <unit> at <tmp> line 1
vrurg Not the best error message one could expect. ;)
jmerelo vrurg: not really... 17:42
vrurg: but I think the problem is that $a is not initialized, so contains something that can't be really converted to Int. That could be a better message, of course... 17:43
vrurg jmerelo: it's an easy thing to fix. Real operators are defined with :D where they should have it.
m: my Str $s; say $s ne "foo"
camelia Use of uninitialized value of type Str in string context.
Methods .^name, .perl, .gist, or .say can be used to stringify it to something meaningful.
True
in block <unit> at <tmp> line 1
vrurg This is more like it.
jmerelo vrurg: and Bridge is a Real method: docs.perl6.org/routine/Bridge 17:45
vrurg jmerelo: yep, it is.
I just have tried infix:«>» with Real:D and got more consistent message: 17:46
Use of uninitialized value of type Int in numeric context
in block <unit> at -e line 1
False
This is how it must be, I think.
jmerelo vrurg: the problem is probably in the context conversion. string context is clear. But in numeric context, there are multiple types of numbers. Default numeric context seems to be Real, so you're going to get those weird messages
m: my Rat $a; say $a > 0 17:47
camelia Cannot look up attributes in a Rat type object
in block <unit> at <tmp> line 1
jmerelo Now that's weird.
my Real $a; say $a > 0
m: my Real $a; say $a > 0
camelia Invocant of method 'Bridge' must be an object instance of type 'Real', not a type object of type 'Real'. Did you forget a '.new'?
in block <unit> at <tmp> line 1
vrurg With Real:D: Use of uninitialized value of type Rat in numeric context 17:48
tony-o notable6: deathbyperl6.com/whats-in-an-orm/ 17:48
notable6 tony-o, I cannot recognize this command. See wiki for some examples: github.com/perl6/whateverable/wiki/Notable
AlexDaniel use weekly: foo 17:49
vrurg I mean, if you constrain operators to act on defined Reals you'll get consistent error message across types – would it be any kind of number, or string.
tony-o weekly: deathbyperl6.com/whats-in-an-orm/
notable6 tony-o, Noted!
tony-o thanks AlexDaniel
AlexDaniel maybe notable6 should be called weeklyable :X
nobody is using it for any other purpose
tony-o lizmat: i tried signing up for cpan a couple of times, every time i never get an email with the password
jmerelo AlexDaniel: do you think it would be worth the while to add to the problem-solving-repo something about Rakudo's PRs and issues? 17:50
AlexDaniel jmerelo: like what?
jmerelo AlexDaniel: like addressing them 17:50
AlexDaniel jmerelo: hmm… I don't understand the question, maybe I'm missing some context? 17:51
jmerelo AlexDaniel: there's like 1 issue closed every 3 days, and 3 issues opened every day. Some of them might be interesting, some not. Some of them are not even labelled.
AlexDaniel: some PRs are 6 years old. They should probably be closed. 17:52
tony-o password reset on cpan gives me: Sorry, the PAUSE failed to send an email.
Administration has been notified.
jmerelo AlexDaniel: I know the priority is to get the new versions going, but at some point in time something should be done about those issues. If they are not legitimate issues, just close them or "won't fix" is enough. 17:53
AlexDaniel jmerelo: lucasb++ worked hard on making the labels more useful and labeling unlabeled things (during the last two weeks or so)
jmerelo AlexDaniel: still. Look at this one: github.com/rakudo/rakudo/issues/1209
AlexDaniel jmerelo: yes, there's a problem 17:54
jmerelo AlexDaniel: not labeled, lizmat waiting for her question to be answered... At least that one is (somewhat) addressed...
jmerelo AlexDaniel: look at the first one, which mentions fail.rakudo.party github.com/rakudo/rakudo/issues/1199 Either change it to blin, or close it... 17:55
AlexDaniel jmerelo: fail.rakudo.party is still a thing, and I think it's a good idea to list github tickets there… 17:56
jmerelo AlexDaniel: OK, but that's not my point. If that's the case, it should maybe get addressed... to check that out and close it. 17:57
AlexDaniel jmerelo: yeah, but so is the case with many other tickets
jmerelo: now, what's the connection with problem-solving repo? 17:58
jmerelo AlexDaniel: the thing would be to ask for a part of the time devoted to new releases to go instead to solving old issues and PRs. Mainly PRs, but also issues.
AlexDaniel: have whoever is the patch pumpkin assign them to whoever is active at every moment, for instance. Or have a policy of having people review them. 17:59
AlexDaniel jmerelo: you wanna create a ticket like “We get more new tickets than we close”, and discuss our options?
jmerelo AlexDaniel: do _something_ about them, anyway.
AlexDaniel: That's the gist of it, yes. 18:00
AlexDaniel jmerelo: sure! Feel free to
jmerelo AlexDaniel: OK
Geth doc: 30b1bfd095 | (JJ Merelo)++ | 2 files
Leaving references to PREVIEW

It's a explanation of pragma. Added some clarification about where it can be found. Also reflow and some corrections.
18:18
chakli p6: my $a="1-2 , ABCa!"; $a ~~ s/<[0..9 , \s ! - ]>+//; say $a 18:39
camelia ABCa!
chakli why is ! not replaced here? 18:40
timotimo probably needs a :g for "global" 18:42
tony-o p6: my $a="1-2 , ABCa!"; $a ~~ s:g/<[0..9 , \s ! - ]>+//; say $a 18:44
camelia ABCa
chakli oh, Yeah. Thanks. 18:45
sena_kun m: class M does Positional {}; class A { multi method a(M $a) { say "M" }; multi method a(Positional $pos) { say "Pos" } }; A.a((1,2,3)); A.a(M.new); 19:03
camelia Pos
M
cpan-p6 New module released to CPAN! Grammar-PrettyErrors (0.0.1) by 03BDUGGAN
sena_kun I can rely on this win of M, right?
tony-o should be able to 19:15
sena_kun I hope so, Perl 6 wouldn't betray me over something so simple. :) 19:17
cpan-p6 New module released to CPAN! db-xoos (0.0.13) by 03YNOTO 19:33
hankache Hello #perl6 19:54
hankache m: class a {has Int @.a-val;}; class b {has Int @.b-val;}; class ab is a is b {method plot {say @.a-val;say @.b-val;}} ;my $ab = ab.new(a-val => (10,9,11,8,7,10), b-val => [9,8,10,7,6,9]); $ab.plot; 20:00
camelia [10 9 11 8 7 10]
[]
hankache why is this not working?
sena_kun 6c: class a {has Int @.a-val;}; class b {has Int @.b-val;}; class ab is a is b {method plot {say @.a-val;say @.b-val;}} ;my $ab = ab.new(a-val => (10,9,11,8,7,10), b-val => [9,8,10,7,6,9]); $ab.plot; 20:02
committable6 sena_kun, gist.github.com/d99c829cd85f182e85...e16ae6b008 20:02
sena_kun that's a regression
timotimo proofread my blog post? :) 20:03
wakelift.de/p/2dc5d8df-2b40-4706-8...d90d569b7/
sena_kun hankache, you should file a rakudo issue with this code.
hankache sena_kun will do. thanks 20:04
Geth ecosystem: 11112316a0 | (Timothy Totten)++ | META.list
Add XML::Entity::HTML to ecosystem

See github.com/supernovus/xml-entity-html
ugexe m: class A { has $.a; }; class B { has $.b }; class C is A is B { }; say C.new(:a(1), :b(2)) 20:05
camelia C.new(a => 1, b => Any)
ugexe a bit shorter
sena_kun m: class A { has $.a; }; class B { has $.b }; class C is B is A { }; say C.new(:a(1), :b(2)) 20:06
camelia C.new(b => 2, a => Any)
hankache 6c: class A { has $.a; }; class B { has $.b }; class C is B is A { }; say C.new(:a(1), :b(2)) 20:07
committable6 hankache, gist.github.com/e854d4a6c9b0be9078...0dd76ec0f7 20:07
hankache ugexe thanks 20:07
ugexe looks like it was already bisected colabti.org/irclogger/irclogger_lo...03-22#l267
hankache was it reported or should i open an issue? 20:09
Geth doc: 234352b270 | (Trey Harris)++ | doc/Type/Signature.pod6
Type/Signature: changed confusing variable name

The variable `$closure` seems a bit prone to creating confusion here; while the variable itself _is_ participating in a closure, closing over the returned anonymous sub, we usually use "a closure" in the nounal form to refer to a function enclosing something or ocassionally to refer to a variable whose use is integral and obvious to the ... (20 more lines)
synopsebot Link: doc.perl6.org/type/Signature
hankache issue submitted 20:18
guifa Is there a way to refer to take objects inside of a gather other than storing them in a list prior to taking them? 21:02
guifa something like, my @foo = lazy gather { for @bar { take $_ unless $_ (elem) @foo } 21:03
sena_kun well 21:06
oh, I failed. never mind me.
ugexe how would that even work? 21:07
checking that an element exists in the array you havent populated
before adding it
which means you have to understand beforehand that you are inside of a lazy iteration and that referring to @foo could only possibly mean the lazy values created up until that point 21:08
guifa ugexe: that was actually the point :-)
moritz but checking with (elem) would reify @foo, which blocks the 'gather', so deadlock
Xliff \o 21:09
guifa Basically to only grab the unique values from @foo, but lazily (.unique doesn’t work, because the take bit isn’t a straight assignment)
Xliff m: sub a(Str @a) { say "Hi!"; }; a((1, 2, 3))
camelia Type check failed in binding to parameter '@a'; expected Positional[Str] but got List ($(1, 2, 3))
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1
Xliff m: sub a(Str @a) { say "Hi!"; }; a(<a b c>) 21:10
camelia Type check failed in binding to parameter '@a'; expected Positional[Str] but got List ($("a", "b", "c"))
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1
ugexe unique works
Xliff m: sub a(Str @a) { say "Hi!"; }; a(<a b c>.Array)
camelia Type check failed in binding to parameter '@a'; expected Positional[Str] but got Array ($["a", "b", "c"])
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1
Xliff m: sub a(@a) { say "Hi!"; }; a(<a b c>.Array)
camelia Hi!
Xliff m: sub a(@a) { die "Dur!" unless @a.all ~~ Str; say "Hi!"; }; a(<a b c>.Array)
camelia Hi!
Xliff m: sub a(@a) { die "Dur!" unless @a.all ~~ Str; say "Hi!"; }; a((1, 2, 4)) 21:10
camelia Dur!
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1
guifa .unique is lazy, even after .map’ing it?
ugexe m: my $foo := unique gather for (1,2,3,4,4,4,4,5) { take $_ }; say $foo
camelia (1 2 3 4 5)
Xliff m: sub a(@a) { die "Dur!" unless @a.all ~~ Str; say "Hi!"; }; a(('a', 4))
camelia Dur!
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1
21:11
Xliff m: sub a(@a) { die "Dur!" unless @a.all ~~ Str; say "Hi!"; }; a(('a', 'b'))
camelia Hi!
ugexe why wouldn't unique be lazy? its not like sort 21:12
not be lazy^
TreyHarris If you need something fancier than unique can manage (though the :as and :with make it hard to understand what would be fancier), you can use a state array or *Hash variable in the gather, push each value you take, and do your check as needed. 21:13
ugexe that is also not the same memory wise 21:14
TreyHarris I can't think what the gather's block would have that unique's :as and :with wouldn't have access to--in the case of a lazy, they'd be called at the same time, I believe? 21:18
ugexe you could certainly code a similar unique, but that is not what implementing with an array and hash really implies 21:21
sena_kun m: my Array[Int] $a = Array[Int].new(1,2,3); $a = $a.map(* + 2); 21:22
camelia Type check failed in assignment to $a; expected Array[Int] but got Seq ($((3, 4, 5).Seq))
in block <unit> at <tmp> line 1
TreyHarris Right, the unique is better--I was trying to imagine a case unique couldn't handle. I can't think of a non-contrived one. But if you could come up with one, it could be solved albeit less performantly
sena_kun is there a way to map values but preserve the type container?
timotimo guifa: you can use the sequence operator with a generator code block that takes a slurpy array argument, that will have all values so-far in it 21:24
ugexe ah for some reason i thought you were suggesting something else
sena_kun oooh, I probably can workaround it unrolling the map by hands.
guifa I think ugexe’s will actually probably work. I think I’m just going a bit crazy coding this logic 21:26
guifa . o O ( this must be why the RFC didn’t include many samples )
timotimo i only looked at the initial question, tbh; i didn't look at what other suggestions there were 21:27
sena_kun m: my $type = Int; my Array[$type] $ints = Array[$type].new 21:35
camelia Type check failed in assignment to $ints; expected Array[Any] but got Array[Int] (Array[Int].new())
in block <unit> at <tmp> line 1
sena_kun what am I missing?
lizmat m: BEGIN my $type = Int; my Array[$type] $ints = Array[$type].new 21:36
camelia ( no output )
lizmat sena_kun: the parameterization happens at compile time. At that moment, $type is not set yet 21:37
adding the BEGIN makes it set **before** the parametarization happens, so then it works
m: BEGIN my $type = Int; dd my Array[$type] $ints = Array[$type].new
camelia Array[Int] $ints = Array[Int].new()
sena_kun no workaround besides this? 21:38
lizmat EVAL ?
sena_kun the issue is that BEGIN won't help me here.
lizmat m: BEGIN my $type = Int; dd my Array[$type] $ints .= .new
camelia 5===SORRY!5=== Error while compiling <tmp>
Malformed mutator method call
at <tmp>:1
------> 3$type = Int; dd my Array[$type] $ints .=7⏏5 .new
expecting any of:
dotty method or postfix
lizmat m: BEGIN my $type = Int; dd my Array[$type] $ints .= new 21:39
camelia Array[Int] $ints = Array[Int].new()
sena_kun hmmm... actually, I can probably create a custom container that will hold an array and a type.
lizmat in any case, that would be shorter
sena_kun oh, I see the issue with my approach. ok, thanks. 21:40
TreyHarris From the docs, these would seem to be kosher, but isn't: 22:04
m: sub make-array(::D $item --> Array[D]) { my Array[D] $f .= new($item); return $f }; say "compiled"; my $a = make-array(42);
camelia compiled
Died with X::TypeCheck::Assignment
in sub make-array at <tmp> line 1
in block <unit> at <tmp> line 1
Geth doc: uzluisf++ created pull request #2691:
Revise examples in the intro to lists.
22:09
TreyHarris Am I misreading the docs on capturing types in signatures? Or is the above a rakudo issue? 22:14
TreyHarris m: sub make-int(Int $item --> Int:D) { return $item.clone }; my $s = make-int(42); say $s; 22:18
camelia 42
TreyHarris With explicit typing it works fine 22:18
Or I guess more closely 22:19
m: sub make-array(Int:D $item --> Array[Int]) { my Array[Int] $f .= new($item); return $f }; say "compiled"; my $a = make-array(42); say $a 22:20
camelia compiled
[42]
TreyHarris m: sub generic-sub(::T $item) { my T $x = $item; return $x }; say generic-sub(42) 22:24
camelia 42
TreyHarris m: sub generic-sub(::T $item) { my T $x = $item.perl; return $x }; say generic-sub(42) 22:25
camelia Type check failed in assignment to $x; expected Int but got Str ("42")
in sub generic-sub at <tmp> line 1
in block <unit> at <tmp> line 1
TreyHarris Hmm... So T can be used in the body, but not in the signature?
that's not right either: 22:28
m: sub generic-sub(::T $item1, T $item2) { my $x = ($item1, $item2); return $x }; say generic-sub(42,40); say generic-sub(42, "Forty-two")
camelia (42 40)
Type check failed in binding to parameter '$item2'; expected Int but got Str ("Forty-two")
in sub generic-sub at <tmp> line 1
in block <unit> at <tmp> line 1
TreyHarris Huh, even this doesn't work for some reason, it's typing T as Int, not Cool: 22:32
m: my Cool \one = 42; my Cool \two = "Forty-two"; sub generic-sub(::T $item1, T $item2) { my $x = ($item1, $item2); return $x }; say generic-sub(42,40); say generic-sub(one, two) 22:33
camelia (42 40)
Type check failed in binding to parameter '$item2'; expected Int but got Str ("Forty-two")
in sub generic-sub at <tmp> line 1
in block <unit> at <tmp> line 1
tobs m: my Cool \one = 42; say one.^name 22:34
camelia Int
tobs (not that I know more than this about the issue, TreyHarris :-/) 22:35
TreyHarris tobs: good point, I'm having trouble getting a Cool value no matter how I write it--it seems to collapse to its constituent type as quickly as possible... like `sub whats-Cool(Cool() $x) { say $x.WHAT }` never says Cool 22:40
timotimo published that blog post: wakelift.de/2019/03/22/intermediat...snapshots/ 22:41
lizmat weekly: wakelift.de/2019/03/22/intermediat...snapshots/ 22:42
notable6 lizmat, Noted!
TreyHarris m: sub foo(Cool(::T) $x, Cool(T) $y) { return ($x, $y) } 22:44
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in typename; couldn't find final ')' (corresponding starter was at line 1)
at <tmp>:1
------> 3sub foo(Cool(::T) $x, Cool(7⏏5T) $y) { return ($x, $y) }
Geth marketing: uzluisf++ created pull request #24:
Add alternate logo
22:45
TreyHarris The Cool thing seems like a separate issue though, I was just trying to create a common supertype without creating my own classes in the example
TreyHarris I think type constraints are checked in a way that's unintuitive to me. I mean, it feels to me like this should work, but it doesn't 22:53
m: sub hm(Bool $p) { say "$p as {Str($p)} is {so $p}." }; hm(42 but False);
camelia Type check failed in binding to parameter '$p'; expected Bool but got Int+{<anon|1>} (42)
in sub hm at <tmp> line 1
in block <unit> at <tmp> line 1
TreyHarris m: sub hm(Bool $p) { say "$p as {Str($p)} is {so $p}." }; hm(False but 42); 22:54
camelia False as False is False.
TreyHarris m: sub hm(Bool $p) { say "$p as {Str($p)} is {so $p}." }; hm(False but "True"); # truly odd?!? 22:57
camelia True as True is True.
TreyHarris m: sub hm(Bool $p) { if $p {say "YES, $p as {Str($p)} is {so $p}."} else {say "NO, $p as {Str($p)} is {so $p}."} }; my $x = False but "True"; hm($x); say "yes" if $x; say "no" unless $x; 23:06
camelia NO, True as True is True.
no
TreyHarris It gets weirder and weirder. 23:07
ugexe `42 but False` <-- what do you think this does that 42 should be a Int|Bool ? 23:09
TreyHarris well, going by the examples that Larry first presented, vs 23:14
m: my $z = 42 but 'forty-two'; say $z; say "{+ $z}"; say $z + 0; say $z.WHAT;
camelia forty-two
forty-two
42
(Int+{<anon|1>})
TreyHarris It seems a bit reversed 23:15
tobs that makes sense to me. 23:17
TreyHarris In particular, I don't quite get why (0+$z).Str and (+$z).Str are different
timotimo +$z on an Int probably just returns self 23:18
tobs well that, I can only speculate that since $z is Int, +$z is a real no-op, whereas 0+$z constructs a new Int
tony-o think i have a patch for `require xyz:file<path>;` merging symbols to `xyz` 23:23
ugexe m: my $x = 42 but "fourty-two"; say $x.Int 23:26
camelia fourty-two
ugexe m: my $x = 42 but "fourty-two"; say $x.Num
camelia 42
ugexe thats certainly interesting
TreyHarris I understand why `42 but False` is an ad-hoc mixin type. I don't understand why it _can't_ be `(Int|Bool)+{<anon|*>}`. And I don't understand why the output «NO, True as True is True.␤no␤» was produced above. 23:27
It feels like "42 but False" is saying you want the value to be conformant to Bool as well as to Int, and not just by dint of Ints being generally conformant to Bool 23:28
ugexe wouldn't such a type have to be known at compile time? sure that can probably be determined from `but False` but for more general `but ...`?
TreyHarris Well, since the 'but' syntax was motivated by kludgey "0 but true" return values... 23:29
I mean, I recognize Failure is used in those contexts and is a better solution to the motivation. But that doesn't make the behavior less surprising 23:30
tobs `$x but $obj` creates and mixes in a new role that has "a single method named the same as $obj.^name and that returns $obj". If $obj is a Bool, that role is not the same as a Bool (Bool isn't even a role). 23:31
ugexe did you know? you can do `0 but True` from CLI! 23:32
sub MAIN(:$number) { say $number; say so $number }
evalable6 (Any)
False
ugexe --/number=1
m: sub MAIN(:$number) { say $number; say so $number }; BEGIN @*ARGS="--/number=1" 23:33
camelia 1
False
ugexe (thats really 1 but False but whatever)
ryanth m: (5... ^10).join(',').say; # This is how my day's been going. 23:37
camelia 5,4,3,2,1,0,1,2,3,4,5,6,7,8,9
timotimo haha 23:39
TreyHarris tobs: Sure, but roles autopun from values and vice versa
timotimo m: (1 ... 10 ... 4 ... 20).join(",").say
camelia 1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 23:40
ryanth Heh, yeah that's definitely a fun operator. Slightly less fun after spending half an hour tracking down a single whitespace character bug. ;-) 23:41
TreyHarris It's a bit like the Cool stuff I was messing with above; it seems that you can't control coercion from the calling side, the best you can do is create a second temporary value of the exact type you want the coercion to see
timotimo ryanth: i wish i had an idea for how to make that easier to figure out :| 23:43
ryanth Indeed. I thought maybe an easily disabled warning if there is whitespace around ... but that has problems of its own. 23:44
ugexe m: sub whats-Cool(Cool(Mu) $x) { say $x.WHAT }; whats-Cool(Cool.new) # you said this never says Cool :P 23:46
camelia (Cool)
timotimo comma could highlight it ;)
tobs TreyHarris: yes, scratch my last half-sentence. What I wanted to say is that "but False" merely changes how the value coerces to Bool by mixing in a role derived from the value False. I wouldn't expect that to add Bool as an alternative to the value's type.
TreyHarris Perl's almost never had whitespace sensitivity in any place that everyday code tidying might affect; this is unusual in being a case where it has a big effect.
ryanth ^
I'm still trying to get my head out of Perl5 and into Perl 6 though, so I'm still extremely biased. :-) 23:47
timotimo i'm not sure i understand; what about foo(blah) vs foo (blah)?
you might be tempted to split the opening parenthesis off when splitting an argument list across multiple lines perhaps? 23:48
tobs m: ^10 ==> map { $_ ** 2 }␤==> my @a; say @a # ever been bitten by this? :-)
camelia 5===SORRY!5=== Error while compiling <tmp>
Bogus statement
at <tmp>:2
------> 3^10 ==> map { $_ ** 2 }7⏏5<EOL>
expecting any of:
postfix
prefix
statement end
term
tobs m: ^10 ==> map { $_ ** 2 } ==> my @a; say @a
camelia [0 1 4 9 16 25 36 49 64 81]
TreyHarris ugexe: I meant with values of subtypes of Cool... I'm not sure "Cool.new" is useful. Cool.new("str") or Cool.new(1) throws errors 23:49
tobs Vertical whitespace is significant there. After a closing brace it acts like a semicolon
ugexe i code using *only* Cool.new -- its turing complete 23:50
TreyHarris ryanth: I don't think "Perl 6 is whitespace-sensitive in ways that Perl 5 is not" is an expected part of the headspace retraining, though
Certainly not in the way that if you're learning Python, you're told up front you need to care about whitespace 23:51
ryanth_ The "Traps" page is pretty good, but it could perhaps be organized a bit better. There is a "Whitespace" section near the top, but the bit about the ... operator is under the Operators section. I already knew about it and it was just a typo in my case, but I could see this information being easily missed by someone new. 23:53
docs.perl6.org/language/traps#Operators 23:54