»ö« 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.
Voldenet there's the same problem with running exec with Inline::Perl5, not surprising 00:00
geekosaur only reason I can think of is Solaris portability and even there you're asking for trouble (reads that would block return 0/EWOULDBLOCK, and you need to clear and check errno to determine it doesn't mean EOF!)
timotimo i wish somebody would champion an API to give more FDs to spawned processes ...
geekosaur also if you are dealing with a Solaris old enough to need that... 00:01
Voldenet legacy reasons
geekosaur I think that's Solaris *1*
(aka SunOS 4 late releases)
Voldenet FIONBIO used to be the only way to deal with sockets 3┐4(5 ̄6ー7 ̄8)9┌ 00:02
geekosaur yes, in the 4BSD days
Voldenet some people never gave up the habit :D
geekosaur O_NDELAY was badly specced on BSDs, and the System Vs that picked up the BSD APIs, which is why O_NONBLOCK. but still. 00:03
SVR4 is how old now?
Voldenet 34
timotimo 1934, or 34 years old? :P 00:04
geekosaur um, that'd be System V itself, not R4
34's about as long as I've been in computing
whioch would be right for SVR1
timotimo i haven't been in anything for that long …
Voldenet well, due to ugly old standards i'll be reimplementing half of unix in perl6 00:05
Belial Any notable projects in Perl 6? 00:30
raschipi Went away. 00:45
lucs pelevesque: Welcome :) 01:11
Voldenet eh, too bad I can't use filehandle with IO::Handle or IO::Pipe 01:18
Voldenet because it internally uses MVMOSHandle which uses uv_pipe_t 01:19
Voldenet hm, it appears the fastest way of getting pid of the spawned process, would be... eh, fixing MVM_proc_spawn and/or MVM_proc_shell 01:26
and not reimplementing half of the mvm's features
why can't i just do that (`Д´)ノ︵ ┻━┻ 01:27
raschipi ┬─┬ノ(ಠ_ಠノ) 01:30
BenGoldberg . o O (You have been flipped by the table) 01:39
u-ou flip ME 01:49
Voldenet no-n
AlexDaniel m: say flip ‘me’ 01:53
camelia em
AlexDaniel m: say flip %*ENV<ME>
camelia leinaDxelA
BenGoldberg Voldenet, Take a look at MoarVM/src/io/procops.c ... after uv_spawn( ..., process, ... ) is called, notice that nothing fetches the ->pid out of the 'process' variable. 02:46
Voldenet yeah, I've noticed 02:48
tbh, I'm chasing other thread
MVM_proc_spawn_async actually holds process data
the returned object from MVM_proc_spawn_async is MVMOSHandle 02:49
int get_pid () { MVMOSHandle *handle; MVMIOAsyncProcessData data = handle->data; uv_process_t *uv_handle = data->handle; return uv_handle->pid } 02:52
basically something like this should work (add the ugliness of C syntax) 02:53
so theoretically I could use nqp::spawnprocasync() to get what I want 02:54
my $msvmos-handle = nqp::getattr(nqp::decont($proc-async), IO::Proc::Async, '$!process_handle') 02:58
or rather: my $msvmos-handle = nqp::getattr(nqp::decont($proc-async), Proc::Async, '$!process_handle') 02:59
samcv ugh i want to control this thinkpads keyboard brightness with more than two levels of brightness. off, medium and full are insufficient numbers of settings 04:38
TimToady if linux, alias bl='xbacklight -set' 04:42
oh wait, that's keyboard 04:43
dunno 'bout that
samcv maybe there's no way to do it variably... idk
TimToady I've only seen those three levels on mine 04:44
samcv this will allow you to control it from the OS gist.github.com/hadess/6847281 but 0 1 and 2 are insufficient!
oh well
TimToady never has any keyboard light after suspend anyway 04:45
helps to be a touch typist though :)
samcv yeah. sometimes you want to see i guess. idk this keyboard is different than my x220 and the function keys i can't tell what they are by feel
there's plenty of room on this laptop for a 7 row keyboard :( 04:46
TimToady it turns off slowly, so you could maybe continuously turn it on and off to get something in between :) 04:51
samcv heh 04:52
i'm sure that c program could be sufficiently abusably depending on how the hardware acts
i should try setting it on a loop
TimToady hates capacitive function key strips...
samcv well maybe if we are lucky lenovo will release a throwback thinkpad that has an older style keyboard 04:53
they say they are going to for the 25th anniversary (hopefully)
TimToady hmm, I wonder if there's some similar way to turn the function strip back on after a suspend... 04:58
samcv or maybe they won't but there's no compelling reason to buy their newer products and the only reason i'm currently using this t540 is i repaired my mother's broken work laptop they let her take home after taking the HD out (bsically t was a writeoff for them. drink was spilled all inside it) 04:59
and it makes me sad that i can't shop around to other manufacturers cause others don't have trackpoints 05:00
samcv though i heard their patent expires the end of this year? not sure. that doesn't mean anything will come of it, but you never know 05:14
samcv timotimo, well now i have it cgoing on and off on loop. sleeping 1 sec between every change. time to see how fast i can make it go 05:32
samcv once it gets fast enough it just looks like it's smothely flickerig up and down. quite distracting 05:38
samcv could play with the hex values though. three levels are 0x03 0x43 and 0x83 in hex at offset 0xd in specific linux /sys file 05:42
moritz \o 05:54
hobbs dell used to have trackpoints made by ALPS. Maybe under license? Guess it has been a while though 06:00
I'm in bad shape because I've been using trackpoint keyboards on my home and work PCs for the past 10 years straight 06:01
but they break, and I've run out of stock, and can't find them on eBay anymore
except for the terrible Lenovo ones that are just the bottom half of a ThinkPad
samcv can't find what? keyboards? 06:03
hobbs ones with a proper TrackPoint on them, yes
samcv for thinkpad?
or you mean for PC's like external
those are harder to find 06:04
hobbs yes, external
samcv i want one :3
hobbs and yes, they've gone from hard to impossible lately
this is the one that I've been using: 4.bp.blogspot.com/-PX5z6ZON75I/V3R...8923-1.jpg 06:06
last made in the late 90s, but there were always some on ebay 06:07
until the past year or two, all the old stock must have dried up
I got my hands on a couple SpaceSavers but they're not as good
u-ou i think i will get brian d foys perl 6 book when it arrives 06:16
hi 06:20
examples.perl6.org/categories/cookb...-date.html 06:21
I like how simple that is
Voldenet phew, I finally figured out how to get pid of the process, look how easy it is ix.io/pgy :> 06:25
*cough intensely* 06:26
Voldenet oh, I forgot ix.io/pgA and ix.io/pgB 06:31
u-ou what's the idiomatic way to just create a file? 08:22
like without writing anything to it? 08:23
samcv u-ou, i mean you colud do `spurt "newfile.txt", ""` 08:25
that would work
u-ou yeah
samcv not sure of other ways to do it though.
u-ou true
thanks
samcv that will overwrite a file if it already exists though 08:26
my $IO = "newfile.txt".IO; $IO.spurt("") unless $IO.e 08:28
that would be safer
u-ou ok
skids just open "/tmp/foo", :rw does it. 08:29
samcv it will create a file just by opening it?
skids Yes.
samcv worked 08:30
'blah'.IO.open(:rw) that did it
skids You can't open something that doesn't exist, after all :-)
samcv well it could throw
idk.
you are right :)
heh
.o(wonders do we need to close filehandles if we don't store them in valiables after they are opened?) 08:31
idk if there's garbage collection for filehandles lol
cygx samcv: files are closed in the destructor, but you should not rely on it 08:32
samcv kk
cygx also, if you want to open a file in rw mode, but not create it implicitly, there's :update 08:33
if you want to fail on preexisting files, there's :rx
skids File::Temp is instructive on proper handling of destruction. 08:34
cygx or rather, :rx will fail on preexisting already opened files 08:35
u-ou i ended up writing my script in perl 5 :( 08:43
but only because I needed glob which is unimplemented? 08:44
moritz yes, that sucks, but often you can use dir().grep(some regex) instead 08:47
u-ou ah, thanks 08:51
nadim_ morning. can I define a method inside a method? 08:58
that's a yes. I guess that it is only visible in the parent method scope, right? 08:59
skids m: class A { method foo { method bar { 42.say; }; self.bar(); }; }; A.new.bar(); A.new.foo(); 09:03
camelia 42
42
skids m: class A { method foo { my method bar { 42.say; }; self.bar(); }; }; A.new.bar() 09:04
camelia No such method 'bar' for invocant of type 'A'
in block <unit> at <tmp> line 1
u-ou night 09:06
timotimo Voldenet: i recommend also checking handle_obj for concreteness, lest you access bogus memory when it's an undefined object, and maybe give a different error when the process is null vs when it's not an MVMOSHandle 09:20
Voldenet timotimo: I just copied the pattern used in other method related to MVM_REPR_ID_MVMOSHandle 09:28
timotimo OK, maybe some of those want changed, too. should try if putting in the OSHandle class we use makes any of them crash 09:29
Voldenet timotimo: only if you passed it a undefined process handle, but then process handle is BOOTIO so it can't really by instantiated anyhow 09:35
or can it?
timotimo the point is what happens if you don't instantiate it 09:39
try nqp::pidprocasync(BOOTIO)
El_Che I was so in love with the MAIN cli params flexibility and so extremely annoyed by weird switches-before-params, that I started to look in the src to see how to changed and I met $*MAIN-ALLOW-NAMED-ANYWHERE. How can it be enabled? It's a read only var. 10:11
stmuk_ my $*MAIN-ALLOW-NAMED-ANYWHERE = True; 10:15
yoleaux 21 Mar 2017 08:35Z <lizmat> stmuk_: is there a reason why the P6W is no longer syndicated to pl6anet.org ?
stmuk_ that is fixed :) 10:16
El_Che ah, my 10:42
silly me
thx, stmuk_ 10:43
RabidGravy tadzik, I've added a test to JSON::Unmarshal fot the shaped associative case which was just fixed in rakudo 12:44
github.com/tadzik/JSON-Unmarshal/pull/25
DrForr Just out of curiosity, are any of the JSON modules able to round-trip a JSON file? (That is, preserve ordering and spacing in the data structure? Wasteful, I know...) 12:49
RabidGravy Not that I know of 13:10
DrForr Mumble. 13:11
DrForr I was thinking about a Dist::Zilla-alike whose first and most important feature would be to keep the META file(s) up-to-date :) I wanted to keep the deltas on that file small. 13:14
pmurias should I upgrade t/01-sanity/99-test-basic.t to use 'is-approx' instead of the deprecated 'is_approx'?
pmurias maybe having the tests for is_approx in a deprecated test? 13:23
DrForr Yeah, I'd move them into a separate file so they're easy to delete when the deprecation period is over. 13:25
ilmari if it issues a deprecation warning, there should be a test for that, while the actual use should be using the new form 13:48
El_Che I want to pass positional and named paramter to a method. I thought something like: my @args = ("pos1", "post2", (name1 => 'foo'), (name2 => 'bar')); $foo.method(|@args). It does not work. Is there a way to do that? <== pass named parameters to the method only if they are defined? 14:23
timotimo you need to | a % 14:25
lizmat use a sigilles capture
timotimo |@ will always give positionals
El_Che ic
lizmat m: sub a(|c) { dd c }; a foo => 42, 666
camelia \(666, :foo(42))
El_Che I like the |% solution 14:28
it does not touch the sub
thx lizmat and timotimo
timotimo well, you can also use \(...) to construct a capture
and | that into your call
El_Che I am converting small one liners and snippets of perl5, 6, shell code I use when analysing text into a small lib. So far silly things like frequency of words in a corpus, split text into different files by regex (e.g. chapters). Silly, but in the Human sciences, most people do it manually 14:33
lizmat
.oO( Perl 6 Oneliners )
14:34
El_Che method count-words-in-text(Str $text, -->Int) { return $text.words.elems; } 14:36
priceless
:)
it's more interesting when the user passes several files at once and want a specific format like csv in return
lizmat method count-words-in-text(Str $text, --> Int() ) { $text.words } 14:37
aka, coerce the return value to an Int
it will call elems for you :-) 14:38
El_Che Most of one liners I use are perl5, though. Consolidating them in p6 because I see lots of potential with the new regex
more magic
who needs harry potter :)
lizmat method count-words-in-text(Str $text, -->Int) { +$text.words } # less magic
El_Che that's better 14:39
although good to know about the -->Type() coercion
lizmat m: sub a(Int() $a) { dd $a }; a "42" 14:41
camelia Int $a = 42
El_Che :)
lizmat not only works for return arguments
El_Che and lizmat= 14:43
El_Che my $*MAIN-ALLOW-NAMED-ANYWHERE = True; 14:43
\o/
that made me happy
lizmat you were not the only one :-) 14:44
El_Che most of the time it's like: "ah that's nice" or "pretty cool" 14:44
this was really a huge smile on my face
Notpick: "--switch arg" would be nice, but "--switch=args" is certainly ok 14:45
The first because you can use shell expansion 14:46
--files *
--file ~/Code/foo.txt
lizmat I think there was a reason for that, but I forget right now
afk for a few hours&
geekosaur if your shell is recent enough it should do expansion after = 14:52
(zsh might need a setting tweak) 14:53
El_Che geekosaur: the latest ubuntu has GNU bash, version 4.3.46(1)-release. $deity knows how much older stuff centos runs 15:09
timotimo how come we can take a &by of 1-arity in method min, but not one with two to have it as a comparator? 15:11
and how come Supply.min uses &by for a comparator, but Any.min uses &by as a transformator? 15:12
DrForr Hrm. Is there a split() variant that would give me an even-length list for "a;b;;c".split(";",:adverb) # ? 15:53
Note that 'c' doesn't have a subsequent split() token. 15:54
SmokeMachine $*MAIN-ALLOW-NAMED-ANYWHERE doesn't work with "--"... :( 16:37
www.irccloud.com/pastebin/BgBVwEJn/
gfldex m: dd "a;b;;c".split(";",:k)[0,2 … *] 16:38
camelia ("a", "b", "", "c")
gfldex DrForr: ^^^ 16:39
DrForr Chose a different way, but thnak you, I'll remember that.
gfldex m: say ("f,,b,c,d".split: /","/ ).perl; 16:40
camelia ("f", "", "b", "c", "d").Seq
dogbert17 o/ 16:41
yoleaux 16 Mar 2017 00:35Z <AlexDaniel> dogbert17: irclog.perlgeek.de/perl6/2017-03-16#i_14272417
dogbert17 ok noob p6 question what's a good way to split a string where two characters differ, i.e. "aabbbc" => ("aa", "bbb", "c") ? 16:44
DrForr That's somewhat unusual. I'd look at forward references, assuming those are still in p6. 16:45
DrForr almost has indentation working in ::Tidy. 16:46
dogbert17 DrForr, are you referring to '<?before pattern>' 16:47
AlexDaniel m: say ‘aabbbc’.comb(/(.)$0*/)
camelia (aa bbb c)
dogbert17 oops, AlexDaniel++
AlexDaniel you have to define the problem other way round
dogbert17 nifty solution 16:51
El_Che can a bag be appended/merged to an other bag? 17:00
or HashBag 17:01
timotimo sure, you want (+) for that
El_Che you are sh*tting me. That simple? 17:02
timotimo well, you may want (+)= instead of just (+)
El_Che hehe
AlexDaniel or, you know, ⊎ 17:03
El_Che I guess creating the bags with bag is out of the question and I need a HashBag explicitly? 17:04
AlexDaniel hmm not necessarily 17:05
m: my $a = bag <1 2 3>; my $b = bag <a b c>; my $c = $a ⊎ $b; say $c 17:06
camelia bag(1, 3, b, a, c, 2)
AlexDaniel m: my $a = bag <1 2 3>; $a ⊎= bag <a b c>; say $a
camelia bag(1, 3, b, a, c, 2)
El_Che incredible 17:08
AlexDaniel but maybe if you're dealing with huge bags, then perhaps ⊎ is not going to work that great 17:09
but I'm not sure
El_Che we'll see when we hit that by now. By now my main source is small (700 pages book)
using bags for finding word frequencies 17:10
AlexDaniel wouldn't call that small :D
but yeah, you'll see
El_Che well, the simple poc code worked 17:11
and then I stared refactoring :)
TimToady m: say ‘aabbbc’.split(/<!same>/) # this also works 17:12
camelia ( aa bbb c )
SmokeMachine Sorry, I was wrong...
TimToady well, except that leaves nulls at the end
SmokeMachine m: say ‘aabbbc’.comb(/<?same>+/) 17:13
:(
camelia (timeout)
TimToady m: say ‘aabbbc’.comb(/.[<same>.]*/) 17:13
camelia (aa bbb c)
masak SmokeMachine: shouldn't ever quantify zero-width assertions... 17:14
SmokeMachine masak: makes sense... thanks!
AlexDaniel huh, <same> ?
TimToady it's a 0-width assertion about its surrounding chars 17:15
AlexDaniel ok… github.com/perl6/doc/issues/1259 17:18
SmokeMachine: where did you find it?
m: dd ‘aabbbc’.split(/<!same>/) 17:19
camelia ("", "aa", "bbb", "c", "").Seq
AlexDaniel SmokeMachine: interestingly, you can also do this ↑, except that you get these empty strings on the sides
dogbert17 TimToady, thx for the snippet, didn't know about 'same' 17:20
dogbert17 m: dd ‘aabbbc’.split(/<!same>/, :skip-empty) 17:21
camelia ("aa", "bbb", "c").Seq
AlexDaniel right
dogbert17 TimToady: still there or hiding behind a cricket? 17:23
does P6 have anything like this (which someone pointed out a couple of days ago)? medium.com/rubyinside/the-new-abse....5m5y0opr2 17:25
AlexDaniel ruby is now supporting curly quotes, huh? 17:28
or these were mangled by the website itself? 17:29
El_Che I have a ton of work on the cualitative text analysis itself, but it has been fun working on the quantitative part with Perl 6 17:35
For a 130056 17:42
oops
For a 130056 word corpus, the bag based word frequency counter finishes in 45sec. Nice 17:43
chsanch Hi!, I'm trying to build Perl 6 on a Pocketchip (armv7l), I'm having some build errors, perhaps for not having enough RAM (512MB), I think more RAM it's not an option here, any advice or there is some documentation about it?. Thanks! 19:04
timotimo chsanch: at what point do the errors appear? 19:10
it's impossible to build the rakudo core setting with only half a gig of ram
that's the one that tells you "please be patient" and it'll output "start", "parse", and then crash 19:11
chsanch Yes, it's at the parse stage: "Stage parse : Makefile:470: recipe for target 'CORE.setting.moarvm' failed" 19:14
timotimo yup 19:15
out of ram, and crash
you can make a swap file, of course
chsanch Ok, I'll try that then 19:17
El_Che chsanch: cross compiling? qemu + emulated arm and more memory? 19:54
RabidGravy fwiw, it will build on a Raspberry Pi B with 512MB 19:58
timotimo oh? 20:00
RabidGravy I haven't got one plugged in right now, but it did a month or so ago 20:01
RabidGravy took like forever but hey 20:01
AlexDaniel chsanch: what OS are you using? 20:12
chsanch: I'd just take a package and use that
timotimo do we actually have arm packages? 20:17
gfldex timotimo: packages.debian.org/sid/rakudo-lib 20:19
timotimo: so, not really
chsanch AlexDaniel: I'm using Debian 20:34
AlexDaniel chsanch: there's rakudo 2016.12 in debian testing 20:35
not exactly the latest but possibly good enough
chsanch there's a rakudo version, but it's 2014.07 20:36
AlexDaniel *testing*
chsanch oh, well, I'm using stable
yah, maybe I should upgrade it
AlexDaniel chsanch: you can pull rakudo package only, I don't think it has many dependencies
timotimo yeah, with "pinning"
gfldex there where quite a few bugs fixed since december last year 20:37
building it by hand may be worth it even if it takes the whole night
AlexDaniel well, then you can get 2017.02 from experimental…
gfldex chsanch: you could try to take the source deps from experimental and pull recent changes 20:38
AlexDaniel if you spend 15 minutes on getting it to pin right, you'll never have to spend the whole night to upgrade it :)
chsanch ok, I'll try the experimental option, but tomorrow, it's almost 11pm here .. I'll let you know how it goes. 20:41
Thanks!
Geth doc: 1f08eaacd9 | (Aleks-Daniel Jakimenko-Aleksejev)++ | doc/Type/Proc.pod6
Remove method pid

It does nothing, there are no tests, and there is a rakudo PR to remove it completely.
20:47
nadim Hi, I have this code nopaste.linux-dev.org/?1123015 I want to have a method that takes any number of arrays and some extra named parameters. this takes text and puts it in columns. 20:52
timotimo nadim: watch out, >>.say doesn't guarantee that the says are executed in order 20:54
gfldex m: sub f(**@a, :$foo){ for @a { when Array { say 'Array' }; } }; my (@a, @b); f(@a, @b, :foo); 20:55
camelia Array
Array
gfldex nadim: ^^^
gfldex nadim: please not that **@a will slurp much more then just Array so you have to handle those cases with care 20:55
*note 20:56
nadim **@as is not in a method where anything else but arrays are passed, it works fine in that context 20:58
good to know about >>.say I guess that is because it can get threaded, right? 20:59
timotimo yup
we used to randomize the calling order to force folks to not rely on it
well, not random, just odd-patterned
it was removed due to performance trouble if i'm not mistaken
gfldex the randomisation was removed, not the threading 21:00
nadim ah I see what you mean with **@a, I am using that construct somewhere else I thought you were talking about it. 21:01
so back to (**@a, :$foo), I have tried but it really didn't want to work. if you say this is the way, I will insist, maybe I am just tired 21:02
timotimo there never was threading for that, gfldex 21:04
gfldex i know, your statement about removal was ambiguous
or maybe I'm to tiered too 21:05
all clocks are wrong right now :(
nadim 2 mn an I will post the code I tried (in vain)
nopaste.linux-dev.org/?1123017 21:07
and I guess .map can come in a different order too, is it jusr for loops that come in order? 21:08
gfldex try |@rs in line 3
(I'm guessing with halve a brain) 21:09
timotimo map is in order 21:09
you can .hyper.map or .race.map if you want it to be not-in-guaranteed-order
(of course, might want to wait for jnthn's hyper/race work to be in rakudo before working with it much)
nadim :) 21:10
nadim the second code compiles and run but let's say that the results are not what I want. the :foo I pass becomes parts of the lists and ends up on the display, not what I want. 21:11
gfldex waiting for rakudo not being confused by walking with two legs before asking it to use 12 may be a good idea too :-> 21:12
nadim why crawl when you can warp through the galaxy ;)
timotimo can you show how you're invoking it? 21:13
named parameters never get part of a *@ or **@, you're probably putting "" around the LHS of the =>
or doing something else that passes a Pair object instead of flatening in a named parameter 21:14
nadim $d.display_columns(<line other_line>, $d.get_dump_lines([6..12]), $d.get_dump_lines([1..4]), :width(20)) ;
three lists am :width(20) 21:15
gfldex nadim: I am now certain that you have to .Slip a slurpy when forwarding it to another slurpy
timotimo oh, do you mean how you call $_.display_columns with "$compact" instead of ":$compact"?
nadim and
timotimo because that's not a named parameter at all
nadim haven't done P6 for a few months, I am rusty it seems
timotimo that's all right
nadim no I called it with :$compact 21:16
the call above, that uses :width(20), is how the first call looks like
should that call use :$foo ? as it seems to work just fine. 21:17
timotimo sorry, "foo"? or "width"? 21:18
:$foo is short for :foo($foo)
so if you're calling it with :width(20) that's already fine
i'm not sure if passing the @rs on like you do in the uppermost method is the right way, i think you'll want to |@rs 21:19
otherwise you're passing the array with arrays as a single positional
but you'll most probably want to pass on $width and $compact in a way that makes them not go into @rs, right? that's why you have to put a : there
gfldex m: sub f(**@a, :$foo){ g(:$foo); for @a { when Array { say 'Array' }; } }; sub g(:$foo){ dd $foo }; my (@a, @b); f(@a, @b, :foo(42)); 21:20
camelia Int $foo = 42
Array
Array
nadim here is the whole code nopaste.linux-dev.org/?1123019
timotimo i must say i find this indentation style really strenuous to read 21:21
nadim display_columns is one version, the one with **@rs, xdisplay_column is another implementation that doesn't take a variable amount of lists
gfldex m: sub f(**@a, :$foo){ g(|@a, :$foo) }; sub g(**@a, :$foo){ dd @a, $foo }; my (@a, @b); f(@a, @b, :foo(42));
camelia [[], []]
Int $foo = 42
gfldex m: sub f(**@a, :$foo){ g(@a, :$foo) }; sub g(**@a, :$foo){ dd @a, $foo }; my (@a, @b); f(@a, @b, :foo(42));
camelia [[[], []],]
Int $foo = 42
nadim I find K&R unreadavle
timotimo we'll soon have DrForr's ::Tidy 21:22
nadim :)
the code you wrote is exactly what I wrote. but it does not work for me 21:23
timotimo is that the code gfldex wrote or what i wrote? 21:24
nadim I didn't even notice you were two :) this irc client gives the same color to both of you :) 21:25
last code gfldex wrote
timotimo at least we have wildly different nick lengths :)
nadim indeed 21:26
but you did not write code.
timotimo yeah, only parts
anyway 21:27
$._display_columns(@rs, $width, $compact)
nadim just spend 3 mn scrolling everywhere
timotimo line 8 or what it is
nadim ok, go on
timotimo that'll pass three positional parameters to the other function
with that call you'll never get $width nor $compact in the _display_columns set to anything
nadim yes I see
a bug indeed 21:28
I checked when you told me but I missed that one
timotimo on top of that, when you go from **@rs and pass @rs to another function with **@rs you'll end up with only one parameter the second time 'round
nadim so how do I do that? 21:30
I must admit that I need to understand ** better, couldn't find a doc 21:31
gfldex what reminds me that I wanted to write down that there a slight differences when returning a .Slip over returning |()
nadim is looking forward to the read
gfldex nadim: see docs.perl6.org/type/Signature#Unfl...ned_Slurpy 21:32
and I stopped writing docs. I went back to file issues.
gfldex have a good *, I'm off to bed hoping the clocks will be a little less wrong tomorrow 21:33
nadim night 21:34
timotimo oh, nadim, you need to flatten it with |@rs
nadim ok, be nice, context, and where. I am old, my grand mother broke her leg, I got a hunch back, the IRS is after me, ... 21:36
I call method(list1, list2, list3, :foo) that goes in method(**@list, :$foo) 21:37
which needs to access list1, list2, ...
timotimo yeah, list1, list2, list3 will be reachable as @list[0], @list[1], and @list[2] in that case
and $foo will be True 21:39
nadim method call method2, which has signature **a, $:foo. do I need to |@list before calling the second method?
timotimo not "before"
the call looks like method2 |@list
and then you pass on :$foo (not $:foo, that's something else) 21:40
nadim lyes I meant :$foo, that's a typo here, that not appearing in the code 21:42
what is it btw?
timotimo it's like $^foo but for named instead of positional
so like { $:hello } is the same as -> :$hello { $hello }
just like { $^a } is the same as -> $a { $a } 21:43
nadim hmm flattening **@r does nothing. my @r_flat = |@r is the same as @r 21:48
timotimo yes 21:49
that's because |@r is syntax inside of calls
and list assignment will iterate over the RHS and assign it into containers on the LHS
m: my @foo = (<a b c>, <d e f>, <g h i>); sub do_it(**@r) { my $thing = |@r; dd $thing; my @other = |@r; dd @other } 21:50
camelia ( no output )
timotimo m: my @foo = (<a b c>, <d e f>, <g h i>); sub do_it(**@r) { my $thing = |@r; dd $thing; my @other = |@r; dd @other }; do_it(@foo); do_it(|@foo)
camelia Slip $thing = $(slip($[("a", "b", "c"), ("d", "e", "f"), ("g", "h", "i")],))
Array @other = [[("a", "b", "c"), ("d", "e", "f"), ("g", "h", "i")],]
Slip $thing = $(slip($("a", "b", "c"), $("d", "e", "f"), $("g", "h", "i")))
Array @other = [("a", "b"…
timotimo that's a bit long 21:51
m: my @foo = (<a b>, <d e>, <g h>); sub do_it(**@r) { my $thing = |@r; dd $thing; my @other = |@r; dd @other }; do_it(@foo); do_it(|@foo)
camelia Slip $thing = $(slip($[("a", "b"), ("d", "e"), ("g", "h")],))
Array @other = [[("a", "b"), ("d", "e"), ("g", "h")],]
Slip $thing = $(slip($("a", "b"), $("d", "e"), $("g", "h")))
Array @other = [("a", "b"), ("d", "e"), ("g", "h")]
timotimo now it fits
you see how $thing is a slip, but yother is an array?
in the first example, @other has an extra [ ] around it because i didn't call do_it with |@rs
in the second example it doesn't have the extra [ ] because i slipped it into multiple positional parameters using | 21:52
nadim OK
timotimo i hope that helps at all, instead of being more confusing 21:53
nadim it helps
I dump the data so I see what happens.
and calling with |@r did fix it, the code does what it is supposed to do. 21:54
I will try a few more tests before being happy
timotimo i'm about to head towards bed 21:59
nadim all calls to method(**@) must |@
works perfectly when I put them everywhere
thank for the help, I'll push this tomorrow so we can get multiple Data::Dump::Trees in columns 22:00
actually I should put that in Text::Columnize
dogbert17 AlexDaniel: btw, gist.github.com/dogbert17/ea5855ab...86c2f24f62 22:01
timotimo no
you got the wrong idea from that
AlexDaniel dogbert17: ooooh 22:02
nadim timotimo: the wrong idea?
timotimo if you had to always use | with **@, then we'd just make that the default
the thing is, **@ is about how incoming positional arguments are treated 22:03
whereas |@ is about pretending an array you have is actually many positional arguments rather than just one positional argument
nadim the first call, the one the user makes looks like method(list1, list2, listn, :foo(10)) so the user is flattening the first one
timotimo the user isn't flattening there 22:04
or i'm misunderstanding how you mean that
skids Anyone else getting some native int related spectest failures lately? Don't know if that's recent or due to me upgraded my build env.
AlexDaniel dogbert17: hm, so what does it mean? :) 22:05
nadim I meant that the user is putting the lists in the call, they get grouped together with **@r I need to do the ungrouping in my code, the user not
tomorrow, after work, I'll post the whole thing 22:06
I am at the airport waiting for my flight, I can keep everyone awake
but won't
timotimo oh 22:08
have a safe trip!
i'll just try to wrap things up over in #moarvm and head to sleeps
nadim thank you, Beirut next. I wonder if there is a pm group there. 22:09
timotimo is that the international name of Bayreuth in germany? 22:11
raschipi It's Beirute in Portuguese.
timotimo ah, ok
agentzh hi guys, sorry if it's a newbie question, but i wonder if it's possible to avoid array copying in @lst in this p6 example: my @lst = <foo bar baz>; class A { has @.b}; my $o = A.new(b => @lst) 23:31
p6: my @lst = <foo bar baz>; class A { has @.b}; my $o = A.new(b => @lst); pop @lst; say $o; 23:32
camelia A.new(b => ["foo", "bar", "baz"])
agentzh i hope the `@.b` uses binding in the new() call.
is there any special p6 syntax sugar for this?
raschipi It's always by binding, the array is just marked read-only. 23:34
If you want to avoid marking it read-only, you need is rw. To pass a copy, you'd need is copy.
agentzh interesting 23:35
p6: my @lst = <foo bar baz>; class A { has @.b is rw }; my $o = A.new(b => @lst); pop @lst; say $o; 23:36
camelia A.new(b => ["foo", "bar", "baz"])
agentzh seems like "is rw" still incurs a copy here?
raschipi: any more hints?
raschipi No, you need "is rw" in the function signature, not i9n the class declaration. 23:37
agentzh i just want to use the @ sigil for the class attributes inside the class, which is nicer than $ while avoid paying for the array copying overhead for the class users.
raschipi: can i still use the new method? 23:38
raschipi It can be called "new", but it will have a different signature.
agentzh raschipi: will you give me an example? 23:39
it cannot be easily achieved without overriding new()?
since i have 46 pm6 classes, overriding new() just for this looks quite like a burden to me. 23:40
ideally it can be an easy flag or something. 23:41
raschipi The function signature is what determines what happens, if you use the default method, you'll get the default behavior.
You could define a class that defined a new new method and inherit from it. 23:42
That way every method would inherit your new method instead of the one defined in Mu. 23:43
Every class would inherit, I mean. 23:45
There's nothing magical about "new". 23:47
agentzh raschipi: thanks for help. but i'm afraid inheritance might not work here without using MOP since each class has its own set of array-typed attributes. 23:49
raschipi The default "new" discovers the attributes, doesn't it? Have a look at the source code to see how it's done.
agentzh ideally maybe we could introduce a `is ref` trait for class attribute declarations?
just like the existing `is required` and `is rw` traits?
this is much more flexible. 23:50
raschipi I'm not sure how to make the bot bring the link.
There's no references in Perl6.
agentzh i'm not sure how rakduo works but a perl 6 compiler choose determine the attributes at compile time instead of at runtime using MOP.
the latter can be quite inefficient. 23:51
raschipi It's about what function calling does, not about how the classes are built.
agentzh *can choose to determine
raschipi Objects are all runtime by design.
It's inherent on how Object Orientation should work.
agentzh but the classes can be assumed to be "closed" if no open class operations are seen by the compiler in the current p6 program 23:52
i remember i read that in a synopsis before.
if all the classes are closed, then the compiler can do clever things in new methods, for example.
raschipi Well, but that's a job for the optimizer and the JIT. They should be transparent for the working of the langugage.
agentzh yeah, so it seems a good chance for the compiler to optimize things if the class attributes accept a "is ref" trait. 23:53
so that the user does not have to write such special new() method using MOP or something. 23:54
raschipi Anyway, method calling doesn't know about the structure of the objects. You need to change the signature of the method, not the structure of the object.
agentzh the latter would be hard to optimize.
raschipi Method calling doesn't know about object structure.
agentzh raschipi: but the compiler can definitely take advantage of the object structure if it finds that it is completely safe in doing so. 23:56
optimizers are all about specializations :) 23:57
raschipi It can. But it's transparent for the programmer.
Perl6 has even "deoptimization", when it optimizes for something and the assumptions change later.
agentzh true. i'm proposing the is ref trait for semantics which is open for optimization opportunities.
the latter is just a bonus :) 23:58
raschipi Well, you don't need the trait, the compiler can determine that on it's own.
agentzh but i still need to write special new() methods, which is a burden for the programmer.
and it would be much harder for the compiler to optimize my MOP code completely away than a simple trait hint. 23:59
raschipi That's object orientation for you.
agentzh i've found this very important and common for optimizations.