»ö« Welcome to Perl 6! | perl6.org/ | evalbot usage: 'p6: say 3;' or rakudo:, or /msg camelia p6: ... | irclog: irc.perl6.org or colabti.org/irclogger/irclogger_logs/perl6 | UTF-8 is our friend!
Set by moritz on 22 December 2015.
MasterDuke tushar: Arrays can have holes 00:00
tushar MasterDuke: Thanks. I just read that in the doc. I don't want hole. How can I achieve that? 00:01
MasterDuke but maybe a hole at the end actually truncates the Array and a hole at the beginning doesn't
tushar hmmm.. MasterDuke: thanks.
00:01 mcmillhj left
MasterDuke it is a little odd the difference between holes at the end and the beginning 00:02
i think lizmat did a bunch of the hole work with Arrays, it would probably be good to ask her if that's expected behavior 00:03
geekosaur I think it's Hard to distinguish the two (without leaking risky internals as perl5 is prone to do), whereas the beginning is fixed
00:04 homes joined
tushar hmm.. I was so happy when I use :delete on array to remove last element it gave what I expected. I did something without asking here. But when I try to delete the first element, it didn't work. :( 00:05
gfldex m: my @a = [[1..3], [4..6], [7..9]]; @a.shift; dd @a; 00:14
camelia rakudo-moar 58cf9d: OUTPUT«Array @a = [[4, 5, 6], [7, 8, 9]]␤»
gfldex tushar: :delete is arrayish. .pop and .shift are linked-listish 00:15
tushar hmm..
timotimo except we implement it as a buffer with a start-offset and length that can wiggle around 00:17
00:17 mcmillhj joined
raiph m: my \array = [[1..3],[4..6],[7..9]]; my \inserts = [[<a b>],Nil,[<c d>]]; say insert array, inserts; sub insert (\array, \inserts) { my \index=$=0; for inserts { $_ and array.splice: index,0,@=$_ and index++; index++ }; array } 00:18
camelia rakudo-moar 58cf9d: OUTPUT«[[a b] [1 2 3] [c d] [4 5 6] [7 8 9]]␤»
raiph tushar: is ^^ closer? 00:20
tushar ralph: thanks for your help. 00:21
00:22 mcmillhj left 00:26 homes left, mcmillhj joined 00:27 pierre_ joined 00:31 mempko left 00:35 mcmillhj left 00:50 BenGoldberg joined, aries_liuxueyang left 00:58 tushar left 00:59 mcmillhj joined 01:04 eliasr left 01:05 mcmillhj left 01:07 itaipu left, aries_liuxueyang joined 01:12 mcmillhj joined 01:16 cdg left 01:17 mcmillhj left, mcmillhj joined 01:22 mcmillhj left 01:37 kurahaupo left 01:41 kaare_ joined 01:45 ilbot3 left 01:47 ilbot3 joined 01:49 ccakes left 01:56 Actualeyes joined 01:59 Zoffix__ joined, Zoffix__ is now known as Zoffix
Zoffix I discovered a new law of nature: if you presentation looks OK in 4 different browsers you tried, but looks broken in 5th, when you're presenting, it'll be broken :) 02:00
(wasn't fatal breakage, but ruined the wow effect :)
02:01 khw joined
grondilu Zoffix: that sounds like a rip of Murphy's law 02:02
Zoffix :) 02:03
02:05 noganex joined, zakharyas joined 02:07 labster left 02:08 noganex_ left 02:09 b2gills left 02:10 b2gills joined 02:12 labster joined
Zoffix New post: ""Perl 6: What Programming In The Future Is Like?" (Lightning Talk Slides and Video)": perl6.party/post/Perl-6-What-Progra...re-Is-Like 02:16
02:18 mcmillhj joined 02:21 cdg joined 02:23 mcmillhj left
dj_goku Zoffix: you need a bot that posts all your posts. :D 02:25
.oO( I need a bot that makes bots... )
02:34 pierre_ left 02:38 pierre_ joined 02:45 cdg left 02:58 wamba joined
BenGoldberg m: rand.Str.say; 02:59
camelia rakudo-moar 415461: OUTPUT«0.229272521330113␤»
Zoffix They're very poor passwords :) 03:00
BenGoldberg Zoffix, I'm looking at the slides of your talk, and the pictures are absolutely hilarious :) 03:01
Zoffix :)
03:04 bjz_ left 03:05 Actualeyes left 03:06 labster left
llfourn how do you do the grammar equiv of self."$name"(). ie you want to match against a rule whos name is only known at runtime. I tried <$name> but didn't work. 03:06
03:07 pierre_ left 03:08 Actualeyes joined
llfourn <$regex> is apparently for interpolating a variable as a regex anyway 03:09
geekosaur but that would do it presumably, if the regex is just a rule invocation 03:11
$foo = '<myrule>'; / <$foo> / # or whatever 03:12
03:13 pierre_ joined
llfourn m: my rule foo { .* }; my $foo = "<foo>"; say "blah" ~~ /<$foo>/ 03:15
camelia rakudo-moar 415461: OUTPUT«「blah」␤»
llfourn geekosaur: it works :)
but I don't really get why it must be "<foo>" rather than just "foo" 03:16
oh... it's treating the content of the variable as a regex and then doing the lookup on the content
that's clever
but I wonder if there isn't a less clever way.. 03:17
03:17 pierre_ left
geekosaur maybe 'foo' would work, I'm not having the best of evenings and a bit fuzzy on p6 regex atm :/ 03:17
llfourn geekosaur: it doesn't :\
no worries you have helped me greatly :) 03:18
geekosaur: I've found the answer 03:20
geekosaur looks to me like that's just how it works, poking at grammars in rakudo itself 03:21
llfourn m: my rule foo { .* }; my $foo = "foo"; say "blah" ~~ /<::($foo)>/
camelia rakudo-moar 415461: OUTPUT«No such method 'foo' for invocant of type 'Cursor'␤ in block <unit> at <tmp> line 1␤␤»
llfourn eh that worked for me in a grammar
hmm that's how you do self."$foo"() at least 03:22
it looks like it doesn't do lexical lookup
which is strange because outside of grammars that's what ::(..) is for
03:27 Zoffix left 03:31 pierre_ joined 03:32 Ven_ left 03:34 Ven_ joined, mohae_ joined 03:37 mohae left 03:46 Ven_ left 03:49 Ven_ joined 03:53 bjz joined 04:08 khw left 04:13 AlexDaniel left 04:15 pierre_ left 04:19 nadim left 04:20 pierre_ joined 04:22 aindilis joined 04:25 pierre_ left 04:35 frankD2 joined 04:37 grondilu left 04:40 BenGoldberg left 04:44 c74d joined 04:45 wamba left 04:53 bjz left 04:55 bjz joined 04:57 Cabanossi left 04:59 skids left 05:01 Cabanossi joined 05:02 cyphase left 05:06 cyphase joined 05:16 xxd joined, xxd is now known as xdxdxd
xdxdxd How many total keywords are in perl6? 05:16
05:19 pierre_ joined
TimToady to the first approximation, none :) 05:20
but it really depends on what you mean by "keyword" 05:21
there aren't really reserved words, except insofar as the standard grammar happens to have some defaults
05:21 xinming left 05:22 xinming joined
TimToady m: sub if { say "I'm an interface" }; if; 05:22
camelia rakudo-moar 415461: OUTPUT«I'm an interface␤»
TimToady to the extent there are keywords, most of 'em require whitespace after them 05:23
m: while; 05:24
camelia rakudo-moar 415461: OUTPUT«5===SORRY!5===␤Whitespace required after keyword 'while'␤at <tmp>:1␤------> 3while7⏏5;␤Undeclared routine:␤ while used at line 1␤␤␤»
xdxdxd hm
instead of defining a keyword as reserved
I mean just words that are used generally in perl6 05:25
you know what I mean?
TimToady well, that's a fuzzy set...
xdxdxd hm
TimToady but you could get an idea by looking at the Grammar.nqp file
[Coke] m: say so sink Rat
camelia rakudo-moar 415461: OUTPUT«WARNINGS for <tmp>:␤Useless use of constant value Rat in sink context (line 1)␤False␤»
xdxdxd hm 05:26
TimToady any word that's not mentioned in Grammar.nqp is really just part of the setting library
xdxdxd how many do you think it would be?
TimToady well, again, depends on how you count 05:27
do you count the 'where' that can occur inside of a signature parameter, even though it's not generally available in expressions?
some words are just internal filler 05:28
xdxdxd I don't understand
05:31 frankD2 left
TimToady m: subset Positive of Int where * > 0; my Positive $x = 0; 05:32
camelia rakudo-moar 415461: OUTPUT«Type check failed in assignment to $x; expected Positive but got Int (0)␤ in block <unit> at <tmp> line 1␤␤»
TimToady is "of" or "where" a keyword there? such noise words can only occur within some other construct, not in general expressions
they're just part of the subset construct 05:33
anyway, if you want an idea of how many words there are, look for things of the form :sym<subset> in Grammar.nqp
they'll be in different syntactic categories, so you can decide which ones you want to count 05:34
some of them are symbolic, and some of them are alphanumeric, but in general Perl 6 doesn't care which ones are really "words"
you might say "1 || 2" or you might say "1 or 2" and mean exactly the same thing 05:35
is "or" a keyword? Or is it just an operator?
it's really just a distinction we don't make, which is why the facetious answer of "none" above :) 05:36
there are 540 occurrences of :sym in Grammar.nqp, and many of those are "words", but many of them are just non-alpha symbols, and some of them are abstract and represent multiple symbols 05:39
05:43 domidumont joined
TimToady but we don't really reserve words in the way that keywords are often reserved in languages 05:44
m: my \if = 42; say "cool" if if eq if;
camelia rakudo-moar 415461: OUTPUT«cool␤»
05:44 rgrinberg left 05:45 Actualeyes left
xdxdxd thanks for the good response TimToady 05:46
05:46 Ven_ left 05:47 domidumont left, xdxdxd left 05:48 domidumont joined 05:49 itaipu joined, Ven_ joined 05:51 cyphase left
TEttinger is the zero-width non-breaking space (which used to be the BOM character) a valid identifier on its own in perl6? 05:53
would that be \x{feff} in perl 6?
TimToady use square brackets 05:54
m: say "\x[feff]".ord
camelia rakudo-moar 415461: OUTPUT«65279␤»
TimToady m: say "\xfeff".ord
camelia rakudo-moar 415461: OUTPUT«65279␤»
TimToady well, they're optional
m: say "\x1F4A9" 05:55
camelia rakudo-moar 415461: OUTPUT«💩␤»
TimToady and not arbitrarily limited to 4 hex codes either :)
05:56 cyphase joined
TEttinger m: say "my \if = 42; say "cool" if if eq if;" 05:57
camelia rakudo-moar 415461: OUTPUT«5===SORRY!5===␤Unrecognized backslash sequence: '\i'␤at <tmp>:1␤------> 3say "my \7⏏5if = 42; say "cool" if if eq if;"␤Two terms in a row␤at <tmp>:1␤------> 3say "my \if = 42; say "7⏏5cool" if if eq if;"␤ expecting any of:…»
TEttinger m: say "my \\\xfeff = 42; say "cool" if if eq if;"
camelia rakudo-moar 415461: OUTPUT«5===SORRY!5=== Error while compiling <tmp>␤Two terms in a row␤at <tmp>:1␤------> 3say "my \\\xfeff = 42; say "7⏏5cool" if if eq if;"␤ expecting any of:␤ infix␤ infix stopper␤ postfix␤ statement end…»
TEttinger oh ha 05:58
m: say "my \\\xfeff = 42; say \"cool\" if if eq if;"
camelia rakudo-moar 415461: OUTPUT«my \ = 42; say "cool" if if eq if;␤»
TEttinger m: my \ = 42; say "cool" if if eq if;
camelia rakudo-moar 415461: OUTPUT«5===SORRY!5=== Error while compiling <tmp>␤Malformed my␤at <tmp>:1␤------> 3my7⏏5 \ = 42; say "cool" if if eq if;␤»
TEttinger huh
I guess it isn't?
unless it was stripped in the first print
geekosaur it's a sigil, not an escape
06:00 cpage_ left, pierre_ left 06:01 pdcawley left
TEttinger I was copying this 06:03
m: my \if = 42; say "cool" if if eq if;
camelia rakudo-moar 415461: OUTPUT«cool␤»
TEttinger but trying to replace if with the unescaped unicode for the character with numeric valud FEFF
06:08 pierre_ joined, andrzejku joined 06:09 silug_ left 06:11 canopus left 06:13 pierre_ left 06:15 movl joined 06:17 Actualeyes joined 06:20 itaipu left, canopus joined 06:21 pierre_ joined 06:22 silug_ joined 06:35 andrzejku left 06:46 Ven_ left 06:51 sena_kun joined, labster joined 06:55 andrzejku joined, MARTIMM joined 07:09 mohae_ left 07:14 grondilu joined 07:17 wamba joined
grondilu hello #perl6 07:26
07:30 andrzejku left
DrForr Hello nurse :) 07:39
07:39 pierre_ left
grondilu some thoughts I've had lately (I made it short): 07:40
(but not short enough to paste it here, thus the gist link) 07:41
moritz I don't understand; do you want a lisp-like language on the lower on the higher level? 07:43
*or on
07:43 pierre_ joined, andrzejku joined
grondilu I should not have talked about low/high level, as I'm not sure lisp obeys this classification. 07:44
moritz that doesn't answer my question :-)
is your goal to write in a more lisp-like language?
grondilu there would be a chain of transcompilers, and something lisp-like would be at the bottom of it.
moritz but, machines don't understand lisp-like languages 07:45
so *then* you need a lisp-like compiler to generate machine code
DrForr With the notable exception of the LispM :)
moritz so I don't understand the motivation
grondilu one of the advantage is that it'd make portability easier. 07:46
moritz but what makes lisp-like languages more portable?
grondilu since at the end your compiler would generate something that is easily written in any language.
javascript for instance can do lisp-like languages. Or rather lambda-calculus like.
so your Perl 6 compiler would easily generate javascript code. 07:47
DrForr IIRC there's already a backend in progress for Javascript. 07:48
psch nqp-js: say("hi")
camelia nqp-js: OUTPUT«hi␤»
psch pmurias++
grondilu DrForr: yeah but let's just say I'm a bit impatient. 07:49
DrForr Seems like that worked above :)
psch as for the gist, it definitely sounds possible to me 07:50
the question seems to be practicality -- we need NQP between perl6 and rakudo for bootstrapping and optimizability increase due to a simpler language. what would one need more than one layer inbetween for? 07:51
well, i guess nqp also helps with portability between backends
(also geez inconsistent capitalization, where's my coffee...) 07:52
07:55 andrzejku left
nine Ok, I give up. How the hell can I return nothing at all? 07:57
m: sub take-nothing(|c) { say c }; sub return-nothing() { }; sub return-empty() { return Empty }; sub return-list() { () }; take-nothing(return-nothing); take-nothing(return-empty); take-nothing(return-list)
camelia rakudo-moar 415461: OUTPUT«\(Nil)␤\(slip())␤\(())␤»
nine None of these ^^^ give me an empty capture 07:58
08:00 RabidGravy joined
psch nine: i wouldn't even know how you'd invoke &take-nothing to get \() in c 08:00
nine: oh, wait, is that just with (), as in empty param list 08:01
nine yes
psch m: sub take-nothing(|c) { say c }; take-nothing
camelia rakudo-moar 415461: OUTPUT«\()␤»
psch yeah i don't think you can do that?
i mean, whenever you have something there it has to be something, even if that something means nothing..? vOv
moritz psch: are you on a philosophy trip right now? :-) 08:03
psch moritz: i hope not! i'm waiting on more coffee :)
nine This inability to return just nothing (like an empty list in Perl 5) is blocking another 6 % improvement to csv-ip5xs.pl :( 08:08
08:10 sena_kun left 08:17 frankD2 joined 08:21 frankD2 left
RabidGravy boom! 08:25
08:27 ocbtec joined 08:58 telex left 09:00 telex joined 09:12 wamba left 09:15 zakharyas left, zakharyas joined 09:20 zakharyas left 09:23 rindolf joined 09:24 labster left 09:25 ItayAlmog joined 09:45 aries_liuxueyang left 09:47 aries_liuxueyang joined
ItayAlmog What soe 09:48
09:48 wamba joined
ItayAlmog What does nqp::create(self) do? 09:48
psch ItayAlmog: it allocates the object github.com/perl6/nqp/blob/master/d...own#create 09:50
ItayAlmog: in detail, this means something along the lines of "tell the VM to reserve some memory for the REPR"
ItayAlmog I know. But what is the self repr? Is it somekind of blank repr? 09:52
psch m: class A { method foo { say self } }; A.foo
camelia rakudo-moar 83d733: OUTPUT«(A)␤»
psch ItayAlmog: "self" is the current class. if there's no 'is repr' on the declarator it's most likely P6Opaque
ItayAlmog Ok, thanks 09:53
psch m: class A { method foo { say self } }; say A.REPR
camelia rakudo-moar 83d733: OUTPUT«P6opaque␤»
RabidGravy I still have this perverse desire for user defined reprs 09:56
09:57 AlexDaniel joined
psch i'm not sure that'd really be useful 09:57
dalek osystem: dd925e0 | (Sam Morrison)++ | META.list:
Add JS::Minify module
osystem: 0b79b01 | (Aleks-Daniel Jakimenko-Aleksejev)++ | META.list:
Merge pull request #256 from scmorrison/master

Add JS::Minify module
psch i mean, either you're doing something C-ish, in which case CStruct or Pointer probably work well enough 09:58
or you aren't, and P6opaque does pretty much everything you need
09:58 TEttinger left
psch although i admit that i maybe am just not seeing the use case :) 09:58
RabidGravy I know, I can't actually think of a sensible use case either :) 10:00
but there are specialised reprs for queues and stuff and it just seems right and proper that for those cases no-one else has thought of yet :) 10:01
psch hm, true. i struggle to imagine a way for custom reprs that isn't backend code though 10:02
10:04 araujo left 10:05 araujo joined 10:07 araujo left, araujo joined 10:09 user9 joined 10:11 pmurias joined
pmurias psch: nqp is not a really an intermediate form like grondilu proposed 10:12
psch pmurias: but QAST is, isn't it? 10:13
pmurias QAST is
10:15 itaipu joined
AlexDaniel buggable: help 10:17
buggable AlexDaniel, tags | tag SOMETAG
AlexDaniel buggable: tags
buggable AlexDaniel, Total: 1374; BUG: 936; UNTAGGED: 283; LTA: 119; NYI: 91; JVM: 62; RFC: 58; CONC: 53; SEGV: 38; REGEX: 35; UNI: 30; PERF: 27; @LARRY: 22; POD: 17; TODO: 17; IO: 16; NATIVECALL: 16; BUILD: 11; PRECOMP: 11; TESTCOMMITTED: 10; OO: 9; MATH: 7; STAR: 6; BOOTSTRAP: 5; GLR: 5; OSX: 4; DOCS: 3; REPL: 3; TESTNEEDED: 3; WEIRD: 3; REGRESSION: 2; CONFIGURE: 1; LIBRARY: 1; OPTIMIZER: 1;
AlexDaniel buggable: tag ✓×「)…æ‘
buggable AlexDaniel, There are no tickets tagged with ✓×「)…Æ‘
RabidGravy phew 10:25
10:26 rudolfochrist joined
AlexDaniel note how Æ is uppercase 10:34
♥🦋 10:35
10:35 ItayAlmog2805 joined 10:36 gregf_ left
jnthn has seen that letter too many times to be surprised by its uppercase form :) 10:36
10:38 ItayAlmog left
pmurias grondilu: I guess what you are proposing is called an nanopass compiler 10:38
10:38 ItayAlmog joined
AlexDaniel m: class Foo { has Bar $.x }; class Bar { has Foo $.y } 10:42
camelia rakudo-moar 83d733: OUTPUT«5===SORRY!5===␤Type 'Bar' is not declared. Did you mean 'Bag'?␤at <tmp>:1␤------> 3class Foo { has Bar7⏏5 $.x }; class Bar { has Foo $.y }␤Malformed has␤at <tmp>:1␤------> 3class Foo { has7⏏5 Bar $.x }; class Bar { has Foo $.y }…»
10:42 ItayAlmog2805 left
pmurias grondilu: I had a initial start of a niecza common lisp backend in the past too 10:42
nine jnthn: is there any way a method can return really nothing at all? 10:43
m: sub take-nothing(|c) { say c }; sub return-nothing() { }; sub return-empty() { return Empty }; sub return-list() { () }; take-nothing(return-nothing); take-nothing(return-empty); take-nothing(return-list)
camelia rakudo-moar 83d733: OUTPUT«\(Nil)␤\(slip())␤\(())␤»
nine Or put the question in another way: what's the fastest way to get rid of the slip() in my args Capture? 10:44
jnthn Well, Nil is the normal way to say "I don't return a value" 10:45
nine But it ends up being a value anyway?
jnthn Well, Nil really is a value representing the absence of a value :) 10:46
What's the problem you're trying to solve?
nine is($foo.count_args($foo.nothing), 1); # fails because count_args gets 2 parameters, $self an a wrapped Nil. $foo is a Perl 5 object. 10:48
It works as long as Inline::Perl5 does a lot of flattening and slurpies which cause the slip() to disappear. But a faster implementation just passes it on until it gets wrapped for Perl 5. 10:49
10:50 aries_liuxueyang left 10:51 Zoffix joined
jnthn What does nothing look like? 10:51
Zoffix .tell TEttinger you need a term:<> to make it work. See perl6.party/post/Anguish--Invisible...Data-Theft 10:52
yoleaux Zoffix: I'll pass your message to TEttinger.
nine jnthn: sub nothing { return; }
10:52 cibs joined
nine jnthn: will in list context return () which Perl 5 interpolates at the very first opportunity. 10:52
jnthn But...we don't have list context in Perl 6...or are you thinking to re-write the Nil into () if it's a boundary call? 10:53
nine I know that nothing() has 0 return values. I just need to be able to pass those 0 values into count_args(). Maybe I can use a multi method invoke(Str $package, Str $function, Nil) to detect that... 10:56
10:59 iH2O joined 11:00 rudolfochrist left 11:02 labster joined, labster left
jnthn Yeah, using a multi to match on Nil should be fast also 11:02
11:08 nadim joined
iH2O matching Nil should be fast 11:15
doing nothing should be fast 11:16
related topic: darkness should be faster than light www.youtube.com/watch?v=JTvcpdfGUtQ 11:18
DrForr Isn't it actually possible to do that because of group velocity? 11:21
iH2O group velocity is the fastest of all? 11:23
11:24 wamba left, ItayAlmog2805 joined
iH2O cuz same as parallel processing 11:25
11:27 rudolfochrist joined
DrForr Well, all you really need is an oscilloscope, come to think of it. The electron gun can sweep across the screen in a long ascilloscope tube faster than light, so if you put an obstacle in the way of the sweep you've created a superluminal shadow. 11:27
11:28 ItayAlmog left 11:29 ItayAlmog2805 left 11:31 rudolfochrist left 11:38 iH2O left
lizmat MasterDuke: re holes in Arrays, afaik this is supposed to work like that 11:38
11:41 edehont joined 11:54 pierre_ left
RabidGravy erk, I just broke the CD in my "heritage" "Using Javascript - special edition" 11:56
moritz RabidGravy: on noez. I hear CDs have real vintage value these days 11:57
timotimo which browser ships with the special edition of javascript?
RabidGravy it was Netscape Navigator at the time 11:58
Netscape Navigator 2.0 nonetheless
the book is 23 years old
timotimo hehehe
lizmat RabidGravy: is that an O'Reilly book ? 11:59
RabidGravy no Que - I'm not even sure if they're still going
www.webbasedprogramming.com/Special...va-Script/ 12:02
I do have the pink camel book on the shelf next to it though
lizmat RabidGravy: a quick look at our library doesn't reveal that particular book, so I'm afraid I won't be able to clone you a copy of the CD 12:03
RabidGravy haha archive.org/details/que-special-ed...javascript 12:04
now I'm not sure if I have any CD-Rs around 12:05
dalek c: 70c0d89 | (Tom Browder)++ | doc/Language/modules.pod6:
prettify comments

also show use of tags on module name
12:17 wamba joined 12:24 rindolf left 12:32 rindolf joined 12:34 domidumont left
stmuk_ I'm a Netscape 2.0 manual somewhere I think, a Pink Camel and a BSDI manual 12:36
and a VT220 manual :)
12:37 domidumont joined
timotimo you're a manual? 12:37
stmuk_ errr ^ I've
gfldex i was about to ask how I RTFM :-> 12:38
12:40 ptolemarch joined 12:47 AlexDaniel left, AlexDaniel joined, wamba left 12:48 rgrinberg joined
jkramer m: sub foo { state @xs = []; return @xs }; foo() = <foo bar baz>; say foo 12:52
camelia rakudo-moar 83d733: OUTPUT«[foo bar baz]␤»
jkramer Why is this working with normal return instead of return-rw?
stmuk_ blogs.perl.org/users/shadowcat_mdk/...ondon.html
jnthn Because an Array is a mutable object, and return-rw is just talking about Scalar containers. 12:53
gfldex jkramer: the @-sigil is Array and Array is a container of containers
jkramer Ah, ok
12:53 gregf_ joined
jkramer m: sub foo { state $foo = ''; return $foo }; foo() = 'wombat'; say foo 12:54
camelia rakudo-moar 83d733: OUTPUT«Cannot assign to a readonly variable or a value␤ in block <unit> at <tmp> line 1␤␤»
jkramer m: sub foo { state $foo = ''; return-rw $foo }; foo() = 'wombat'; say foo
camelia rakudo-moar 83d733: OUTPUT«wombat␤»
jkramer \o/
hackedNO1 m: sub foo { state $foo = []; return $foo }; foo() = 'wombat'; say foo
camelia rakudo-moar 83d733: OUTPUT«Cannot assign to a readonly variable or a value␤ in block <unit> at <tmp> line 1␤␤»
12:55 mcmillhj joined
jkramer So do I get this right, in Perl 6 I can basically forget about the old sigils and just use $ for everything because the other sigils are just some kind of indicator/type constraint? 12:56
gfldex no :) 12:57
jkramer Ok :D
jnthn You *could*, but it may not be an entirely convenient experience
gfldex you need them for signatures
jnthn m: my @a = [1,2,3]; for @a { .say }
camelia rakudo-moar 83d733: OUTPUT«1␤2␤3␤»
jkramer Hmm true.
jnthn m: my $a = [1,2,3]; for $a { .say }
camelia rakudo-moar 83d733: OUTPUT«[1 2 3]␤»
jnthn For example :) 12:58
gfldex m: my $a = [1,2,3]; for $a.flat { .say }
camelia rakudo-moar 83d733: OUTPUT«1␤2␤3␤»
gfldex you would need plents of .flat everywhere
timotimo you may not want to .flat, you can also just .list
jkramer Ah, took me way too long to find the difference in the output :D
hackedNO1 m: my $a = [1,2,3]; for |$a { .say }
camelia rakudo-moar 83d733: OUTPUT«1␤2␤3␤»
jnthn If you use .map it works either way, though :) 12:59
jkramer So what exactly is the difference between @x = [] and $x = []?
hackedNO1 m: my @a = 1, 2, 3; dd @a
camelia rakudo-moar 83d733: OUTPUT«Array @a = [1, 2, 3]␤»
hackedNO1 m: my $a = 1, 2, 3; dd $a
camelia rakudo-moar 83d733: OUTPUT«WARNINGS for <tmp>:␤Useless use of constant integer 2 in sink context (lines 1, 1)␤Useless use of constant integer 3 in sink context (lines 1, 1)␤Int $a = 1␤»
jkramer m: my $a = [1,2,3]; dd $a 13:00
camelia rakudo-moar 83d733: OUTPUT«Array $a = $[1, 2, 3]␤»
hackedNO1 m: class { has @.foo }.new: :foo<a>
camelia ( no output )
13:01 Actualeyes left
gfldex also you state intent, what can greatly improve readability 13:01
hackedNO1 m: sub (@foo) {}(1)
camelia rakudo-moar 83d733: OUTPUT«Type check failed in binding to @foo; expected Positional but got Int (1)␤ in sub at <tmp> line 1␤ in block <unit> at <tmp> line 1␤␤»
jnthn jkramer: A Scalar is just a reference to something, so you're taking the Array object created by [] and making the Scalr point to it.
hackedNO1 m: sub ($foo) {}(1)
camelia ( no output )
jnthn jkramer: In my @a = [1,2,3], @a is an Array object, and assignment into it is a copying operation
jkramer So that's pretty much like in Perl 5 but more "transparent" in that I don't have to dereferece $a all the time explicitly? 13:03
gfldex m: sub f(){ 1,2,3 }; my @a = f; dd @a; my $a = f; dd $a
camelia rakudo-moar 83d733: OUTPUT«Array @a = [1, 2, 3]␤List $a = $(1, 2, 3)␤»
gfldex if you look at the $a = part, you may wonder if more then value was expected
13:08 imcsk8 joined 13:09 Actualeyes joined 13:13 gregf_ left 13:17 sufrostico joined 13:20 sftp left
moritz 13:21
13:21 bioduds left 13:22 sftp joined 13:28 zakharyas joined 13:35 skids joined 13:43 FROGGS joined 13:45 gregf_ joined
FROGGS hi, I've got a question even though it is not a question about Perl 6 directly... 13:46
say, I have a bunch of timespans, and I want to display these in a calender (on a webpage)
and the data is like: 13:47
<---------> <------------->
<----> <-------> <-------->
<----------> <---->
what's the right algorithm to sort these timespans? I want to minimize the number of rows used for display 13:48
jnthn Hm, isn't that a kind of packing algorithm?
FROGGS sounds like a good name for it :o) 13:49
arnsholt (Packing problems having a tendency to be NP-complete)
jnthn Yeah... www.aaai.org/Papers/ICAPS/2003/ICAPS03-029.pdf agrees :) 13:52
13:53 cdg joined
jnthn Though it's not quite a traditonal packing problem 'cus the exact horizontal position is constrained 13:53
So only the vertical is up for choosing
13:55 domidumont left
jnthn I wonder if it maps more closely to en.wikipedia.org/wiki/Knapsack_problem 13:56
13:57 domidumont joined
hackedNO1 Sounds like a sudoku solver can figure this out... 13:57
Each line needs to sum up to X, find stuff that matches that, build lines out of it.
and append leftovers. 13:58
FROGGS well, it does not have to some up
I mean, there might be holes
jnthn Did you already see how badly some simplistic greedy approach does (e.g. sort them smallest first and then try to place them on the line(s) you currently have, appending an extra line if not? 14:00
FROGGS well, the result is not ideal... 14:01
jnthn *nod*
FROGGS usally it ends up as:
timotimo it may be np-complete or something, but the amount of data you have surely isn't gigantic?
like, how much data would you need to have to reach an hour of computation time for this task? 14:02
jnthn Why with what I suggested would it not place the second one on the first line?
FROGGS no, it is just a bunch of spans, I guess not more than 20 items a day
timotimo if there's ever spots where no spans overlap at all, you can chop the problem up into smaller pieces 14:03
FROGGS jnthn: no, the second is the longest
timotimo that'll make a gigantic dent in the complexity
FROGGS maybe I just just sort them by time, and then loop over the rows and add them if there is space
and open new rows if it does not fit? 14:04
nemo FROGGS: I personally find it more helpful to not try to pack but instead sort by which timespan starts first
FROGGS: it makes it a lot easier for me to figure out what began when on a large calendar
FROGGS yeah 14:05
nemo I'd say that simplifies your algorithm. Maybe focus on visually fitting them better?
perhaps make them less tall, maybe they could grow on hover
14:05 woolfy left
FROGGS nah, you should be able to see how tall the spans are... 14:05
nemo FROGGS: 10y ago they asked me for a calendar for our local IT team. whipped it up w/ one db table and one query and one dynamic page ☺
calendars are pretty simple 14:06
14:06 woolfy joined
FROGGS it's a calender, with a red "now"-bar so the start and end times need to be correct 14:06
14:06 wamba joined
FROGGS okay, I think I've got a starting point now... 14:06
14:10 zakharyas left
jnthn FROGGS: fiww, gist.github.com/jnthn/ebe9161915c9...707300c974 is what I was thinking of :) 14:13
FROGGS huh, nice 14:15
jnthn++ 14:16
damn how I love this channel
for a little test the result is better when I sort them longest-first 14:18
but that might be coincidence
14:19 donaldh joined
jnthn Yeah, this is fore sure doing a quick approximation 14:19
FROGGS though, the longest span usually is the most important for the user, so it might make sense to see the longest at the top
jnthn ah, yes. :)
FROGGS .oO( it is not just about data, it is about users ) 14:20