Perl 6 - the future is here, just unevenly distributed

IRC log for #rosettacode, 2011-07-15

| Channels | #rosettacode index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:23 mwn3d_phone left #rosettacode
00:25 mwn3d_phone joined #rosettacode
00:35 mwn3d_phone Heh I kinda like the perl 6 ternary operator. ?? And !!. It makes the program seem confused and excited. Did plain perl have that?
01:03 kpreid joined #rosettacode
01:06 TimToady no, only the boring C version
01:08 mwn3d_phone Boooooo! Come on guys...give your code some feeling!
01:22 kpreid left #rosettacode
01:33 ttmrichter joined #rosettacode
01:49 mikemol mwn3d_phone: Have you seen their metaoperator logic?
01:49 mwn3d_phone Nope
01:52 kpreid joined #rosettacode
01:59 kpreid left #rosettacode
01:59 kpreid joined #rosettacode
02:21 mikemol mwn3d_phone: More or less, for any operator, there's are modifer operators your can apply to get analogous behavior for a different circumstance.
02:21 mwn3d_phone left #rosettacode
02:23 mwn3d_phone joined #rosettacode
02:24 mikemol mwn3d_phone: The classic examples are things like +=, *=, %=, /=, etc.
02:24 mwn3d_phone What do those do in perl?
02:24 mikemol Same thing they'd do in C or C++.
02:25 mikemol In Perl6, they've got more than your normal set of meta operators, though. That's why I mention it (in response to your "give your code some feeling" bit :) )
02:25 mikemol Do we have a metaoperator task? Seems like a simple enough principle.
02:26 mwn3d_phone What would it do? "Metaoperator" means absolutely nothing to me.
02:29 mikemol mwn3d_phone: The meta operator, in the case of +=, *=, %=, etc, is the =. You have your +, * and % operators, but the = gives it an analogous behavior in a different context.
02:29 TimToady APL derived languagess also have metaoperators
02:29 mikemol A "meta" operator is an operator on an operator.
02:30 mwn3d_phone Still don't understand. I know what the operators do. But the "analogous behavior" part is where you lose me.
02:30 TimToady it's really a form of high-order function
02:30 mikemol mwn3d_phone: If I said a -= b, you would know what that did, because you know what a = b does, and you know what - does.
02:31 mikemol The = is applied to the -, and you understand -= as - in the context of =.
02:31 mwn3d_phone I don't think I ever separated them much really in my head
02:31 TimToady they're not productive in C
02:31 mwn3d_phone I know what -= does cause that's what -= does
02:31 TimToady they are in APL and Perl 6
02:31 mikemol Hm.
02:32 mikemol mwn3d_phone: If I had an operator b, and I said n b= m, would you know what n b= m did (assuming you knew what the 'b' operator did)?
02:33 mwn3d_phone I guess its like knowing what the german word for "airplane" means because you know its a combination of the words for "flying" and "thing" or because you know what the word for "airplane" is
02:33 mikemol Fair enough. In spoken and written languages, recognition of etymology makes learning and coining new words easier.
02:34 * mikemol is writing a meta-operators task.
02:35 mikemol I immediately discovered that describing unary vs binary operators in conjunction with meta operators can be...interesting.
02:35 TimToady nearly all of our metaops work on infixes
02:36 mikemol TimToady: Out of curiosity, let's say I had an array of thirty integers. Is there a way to say (scalar) -= (array), and have the -= applied to scalar for each element of (array), resolving to a scalar?
02:36 mikemol So, if I had a -= (1, 2, 3), the result would be equivalent to a = a - 6.
02:38 TimToady p6eval: perl6: my $a = 100; $a «-=« (1,2,3); say $a
02:38 p6eval TimToady: pugs: OUTPUT«decodeUTF8': bad data: '\171'␤decodeUTF8': bad data: '\171'␤*** ␤    Unexpected "\171-=\171"␤    expecting operator␤    at /tmp/EGS66BlUJf line 1, column 17␤»
02:38 p6eval ..niecza v7-37-g20310bc: OUTPUT«94␤»
02:38 p6eval ..rakudo 1ddda5: OUTPUT«Cannot modify readonly value␤  in '&infix:<=>' at line 1:src/metamodel/RoleToInstanceApplier.nqp␤  in <anon> at line 219:src/gen/core.pm␤  in 'hyper' at line 1:src/metamodel/RoleToInstanceApplier.nqp␤  in 'hyper' at line 236:src/gen/core.pm␤  in main program body a…
02:38 TimToady looks like niecza manages it
02:38 TimToady you can stack metaops in p6
02:39 * mikemol wonders what circumstances might lead to nested pairs of «
02:41 * mikemol gives up trying to write the meta-op task. He can't come up with a suitable way to describe it.
02:42 mikemol I'd like to get a listing of meta-operators, but I'd also like to get a demonstration of how langauges can fake it if it's not built-in. Getting tired-ish, I guess.
02:45 TimToady well, it's a form of higher-order functions, though syntactic sugar
02:47 mikemol While I have a rough understanding of what higher-order functions are, I don't have a solid enough understanding to be able to explain it clearly.
02:47 TimToady it's just functions that take other functions as arguments
02:48 * mikemol nods
02:48 TimToady in p6, [+] @list is just syntacctic sugar for reduce &infix:<+>, @list
02:49 mikemol Mhy brain just isn't wrapping around the words needed to describe that, particularly in the case of meta operators while simultaneously covering a task genericity/specifity balance. It's late, and I woke up unexpectedly early today. :)
02:50 mikemol I'm struggling just to get a simple X11 app launched over ethernet right now.
02:50 TimToady in APL the same reduction operator would be spelled /+ I believe
02:51 mikemol It might be worth having a task for reduce; I didn't really understand what that was until a few weeks ago.
02:52 mikemol I realize it's old hat to most people here, but, heh... >.>
02:54 mwn3d_phone Sounds good. Lots of languages have it. I'm not too sure what it is myself. Is it like map (which I also don't understand well)?
02:58 mikemol The only way I understand 'map' is Perl 5's "map", which takes each element of a list and applies a block of code to it.
02:59 TimToady that block is a true function in p6
03:30 ttmrichter mwn3d_phone: A reduce (a.k.a. fold) is like a map that keeps an accumulator.
03:30 ttmrichter So like a map (which mikemol correctly described), a reduce goes over each element of a container and applies a block of code.
03:31 ttmrichter Unlike a map, however, there's a second parameter passed to each function which accumulates a result.
03:31 ttmrichter So if you applied the + operator to a list in a fold, you'd get the sum of all the parts by adding the current value being visited to the accumulator.
03:32 mikemol Is the behavior defined if you apply a non-commutative operator?
03:33 ttmrichter It's defined in the same way that applying said non-commutative operator in a for loop that walks the container would be, yes.
03:33 ttmrichter Folds have a "left" and "right" flavour for which direction, in effect, you're walking the container.
03:36 ttmrichter Here's some examples from Haskell:
03:37 ttmrichter foldl (+) 0 [1,2,3,4,5]  Ã¢â€ â€™  15
03:37 ttmrichter This is saying "apply the + operator to each element with a starting value of 0".
03:37 ttmrichter foldl (-) 0 [1,2,3,4,5] → -15
03:38 ttmrichter This is doing the same thing with the - operator.  It's being applied left-to-right.
03:39 ttmrichter Now for the surprising version:
03:39 ttmrichter foldr (-) 0 [1,2,3,4,5]  Ã¢â€ â€™  3
03:39 ttmrichter Here it goes right-to-left.
03:40 ttmrichter So it starts with 5 - 0.
03:40 ttmrichter The accumulator has 5.  Then it does 4 - 5 leaving -1.  Then it does 3 - (-1) leaving 4.  And so on.
03:41 ttmrichter More examples and explanations (at tedious length) here: http://www.haskell.org/haskellwiki/Fold
03:41 fedaykin "Fold - HaskellWiki"
03:48 BenBE left #rosettacode
03:52 BenBE joined #rosettacode
03:52 TimToady Perl 6 goes for a more user-oriented version.  You don't tell it the direction of the fold, it just does what is natural for the operator, by default
03:54 TimToady so [*] is left-to-right, while [**] is right-to-left
03:54 TimToady you can always use the real functions underneath if you dont want the default
03:54 TimToady and the "correct" semantics are defined to be exactly as if you'd put the operator between all the arguments as an infix
03:55 TimToady (though thunky operators are a bit of an exception, since a list doesn't know how to do that)
04:01 ttmrichter What is the "natural" direction for subtraction?
04:02 ttmrichter Or, for that matter, what's the "natural" direction for list filtering?
04:05 TimToady subtraction is left associative, so that's it's natural direction in [-]
04:05 TimToady list filtering isn't an infix, so there's no [op] form
04:06 TimToady but maps go left-to-right by default
04:07 TimToady especially since they're lazy
04:30 ttmrichter Accumulating a list left-to-right means either you get the "Schlemiel effect" or you get a reversed list as output.
04:44 aLeSD left #rosettacode
04:54 TimToady well, we don't get either of those, so check your assumptions
04:58 aLeSD joined #rosettacode
05:18 ttmrichter How do you accumulate a list in forward order without getting the painter's algorithm problem?
05:19 TimToady you're thinking of list as a low-level structure such as in Lisp.  in Perl-land, lists are often just arrays, and either end is just as easy to access in that case
05:19 TimToady you might say our list api is at a slightly higher abstraction level
05:20 ttmrichter OK, so what happens if you have an alias.
05:20 ttmrichter List A and List B point to the same head.
05:20 TimToady generally, you don't in Perl
05:20 ttmrichter Now you add something to the tail.
05:20 ttmrichter Of A, I mean.
05:20 ttmrichter What does B contain?
05:21 TimToady if you need that kind of data structure, you're not talking about Perl lists, but about Lisp lists
05:21 ttmrichter I'm describing the abstract concept of a list.
05:21 TimToady we're not stuck in head/tail land
05:21 ttmrichter So you're gussying up arrays and calling them lists.
05:21 ttmrichter Sounds to me like you're not at a higher level of abstraction.  You're eschewing abstractions entirely.
05:22 TimToady no, we have an api that doesn't enforce a particular view
05:22 TimToady the head/tail abstraction is detrimential to parallelism anyway
05:26 TimToady I prefer Guy Steele's views on this
05:27 ttmrichter But you DO enforce a particular view.
05:27 ttmrichter You enforce a view in which lists are mutable.
05:27 ttmrichter Which is FAR more damaging to parallelism and concurrency.
05:28 TimToady no, our lists are immutable
05:33 ttmrichter Didn't I just ask about lists A and B and adding to the tail of A and the effects on B?
08:15 aLeSD left #rosettacode
08:17 aLeSD joined #rosettacode
08:37 aLeSD left #rosettacode
08:46 aLeSD joined #rosettacode
09:57 aLeSD left #rosettacode
10:02 aLeSD joined #rosettacode
10:24 aLeSD left #rosettacode
11:46 lambdabot left #rosettacode
12:06 lambdabot joined #rosettacode
12:51 mwn3d_phone1 joined #rosettacode
12:51 mwn3d_phone left #rosettacode
13:19 dagnyscott joined #rosettacode
13:36 mwn3d_phone1 is now known as mwn3d_phone
13:43 kpreid mikemol: in E, you can in fact say "n b= m" :-)
13:43 kpreid (and it is defined as n := n.b(m), and a+b is a.add(b))
13:53 mikemol Cool. :)
14:22 axisys joined #rosettacode
14:34 dagnyscott1 joined #rosettacode
14:37 dagnyscott1 left #rosettacode
15:26 kpreid left #rosettacode
16:19 kpreid joined #rosettacode
16:20 mwn3d_phone Oh hey neat. I put up an example page in the form "task/language/example description" without creating "task/language" and MW was smart enough to put a link to "task" up top rather than "task/language".
16:21 kpreid left #rosettacode
16:22 kpreid joined #rosettacode
17:47 ttmrichter left #rosettacode
17:50 mwn3d_phone1 joined #rosettacode
17:51 kpreid left #rosettacode
17:54 mwn3d_phone left #rosettacode
18:00 mwn3d_phone1 is now known as mwn3d_phone
18:07 kpreid joined #rosettacode
18:25 * TimToady goes off to study alphabetical order :)
18:29 mbishop I think that pythagorean triple task helped me find a bug in this language's implementation
18:34 mikemol Cool. I like to hear that kind of thing. :)
18:47 * TimToady is weary of both FP and OO precisionists who think their words are the One True Vocabulary, and just don't grok (or, more charitably, forget temporarily) what "rosetta" is supposed to mean...
18:53 MigoMipo joined #rosettacode
18:54 * mikemol nods
18:55 mwn3d_phone I put something up about disputes over the word "function" in [[user:mwn3d/word mincing]]
18:55 fedaykin http://rosettacode.org/wiki/user:mwn3d/word_mincing (Doesn't exist.)
18:55 mwn3d_phone Hmm....what'd I do wrong there?
18:55 mikemol There's been a lot of that on the wiki in the last month or so, though I think most of that comes from a lack of common vocabulary.
18:55 mikemol mwn3d_phone: Capitalization
18:56 mikemol Or, at least, common-enough vocabulary.
18:56 mwn3d_phone [[user:mwn3d/Word mincing]]? I think the rest capitalizes itself (hopefully)
18:56 fedaykin http://rosettacode.org/wiki/user:mwn3d/Word_mincing
18:57 * Hypftier is probably guilty of the pseudo-random one
18:57 TimToady some communities have some pretty strong shibboleths
18:58 TimToady it's hard to escape your cultural conditioning, so we should have some empathy for folks who are trapped
18:58 mikemol It'd probably be worthwhile to create dictionary pages for common ambiguities.
18:59 mikemol Such as the distinctions between lists, collections, sequences, sets. Distinctions between maps, dicts, hashes. Stuff like that.
19:00 mikemol It might be useful to build a terminology thesaurus. SMW would be well-suited for that kind of thing.
19:00 mwn3d_phone I don't remember many disputes over list/collection/sequence/set/blah but it might be good to be proactive
19:01 kpreid left #rosettacode
19:02 TimToady well, we were disagreeing over "list" just last night :)
19:02 mikemol Also "immutable", apparently, although that may have been mismatched execution context.
19:03 TimToady well, mismatched views of the nature of encapsulation, perhaps
19:03 TimToady p6 lists are immutable on the outside, but that doens't mean the implementation has to refrain from cheating at every moment
19:04 TimToady FPers arent big on the notion of encapsulation, but we have to use that notion heavily to mesh FP and OO gracefully in p6
19:04 TimToady well, as gracefully as possible, anyway :)
19:09 TimToady mwn3d_phone: on the run forever one, it seems a bit overstated; we have run forever loops, where the "external force" is not something outside the program, but a different construct inside the loop that can be viewed on some level as independent
19:10 TimToady that is, for (;;) {...} is in some sense a run-forever loop even if there's a break inside
19:11 mwn3d_phone The "run forever" is in regards to the task description not necessarily the loop used
19:12 TimToady okay, though the fight does break out over loops too :)
19:12 mikemol TimToady: For conversations like the one you had about lists last night, perhaps the better response might be, "it just works, and it has to satisfy (constraint), how it does it is up to the implementation"
19:13 TimToady anyway, I'd just like to say, as the instigator of a multi-paradigmatic language, I appreciate the easy-goingness of RC as a whole
19:14 TimToady mikemol: to which the response might well have been: "well, it doesn't work, you just think it does."  :)
19:14 mikemol Then challenge them to write unit tests showing it doesn't. :)
19:14 TimToady anyway, it was obviously turning into a game of talking past each other, so I abandoned it
19:14 * mikemol nods
19:16 TimToady I've learned it saves me a lot of time not needing to have the last word :)
19:16 mikemol Very true.
19:24 mbishop this Markhobley guy sure is...stirring things up :)
19:26 mwn3d_phone Very diplomatic
19:32 mikemol It's probably a good idea to get him in here and have conversations in smaller bites.
19:40 mwn3d_phone The problem is that some people who are prominent in discussions (paddy and ledrug) also don't hang out here
20:00 mikemol That's true. And I doubt Paddy ever will; he's been invited before.
20:01 mikemol However, the problem, atm, is one of mediation and bridge-building. It's not that they need to be able to talk to each other in a particular context, it's more that someone outside the conversation needs to provide the bits of context and explanation of diffierent points of view.
20:01 mikemol I'd do it, but I'm (a) at work, (b) busy this evening, (c) busy tomorrow pretty much all day. I have no idea what's going to happen on Sunday. Might be busy, might not be.
20:02 TimToady .oO(We all agree on the necessity of compromise; we just can't agree on when to compromise...)
20:02 mikemol Wedding planning, funerals, schedule refactoring, doing my bit in organizing this year's local barcamp. Life's insane.
20:03 mikemol It's not usually so much a matter of compromising as seeing and understanding multiple conversants' mental framework, finding the overlap and building from it.
20:03 mikemol Then finding out where the incompatibilities are, and suggesting that be a different task. :)
20:04 mikemol But I haven't even gotten through yesterday's edits in my rss feed, so I really don't know what today's argument is about.
20:26 MigoMipo left #rosettacode
20:58 kpreid joined #rosettacode
21:20 thundergnat joined #rosettacode
21:25 thundergnat Hi, I'm having some trouble with an image file I've uploaded. It uploaded ok,   but for some reason it is getting an error when generating a thumbnail. I tried regenerating an reuploading, no dice. It opens fine when you look at the full size file.... Any ideas or suggestions? File url: http://rosettacode.org/wiki/File:Coordinate-pairs-perl6.svg
21:26 fedaykin "File:Coordinate-pairs-perl6.svg - Rosetta Code" http://rldn.net/6qO
21:34 Hypftier might just be an rsvg bug
21:34 Hypftier there are plenty of those
21:40 Hypftier hm, it crashes here whenever <text> is in the SVG, but that might just be here.
21:44 Hypftier thundergnat: works now; but text is lost.
21:45 thundergnat hmmm.
21:45 Hypftier Needs probably a bit more twiddling to find the actual cause
21:45 Hypftier I'm fairly sure the rsvg crashes here are due to a poor Windows port; that shouldn't happen on RC, I guess.
21:48 thundergnat Thanks, I'll need to see what you changed. May need to modify the SVG::Plot module if it generates faulty SVG code.
21:48 Hypftier No, the SVG code is perfectly fine.
21:48 Hypftier I only converetd the text objects to paths and preview works again
21:49 thundergnat Ah.
21:49 Hypftier Maybe it doesn't find fonts or something. mikemol could probably investigate the actual cause. I merely did a workaround :)
21:49 thundergnat Sorry, mis-read what you wrote.
21:50 thundergnat Thanks
21:50 Hypftier In fact, the SVG source was very nice. Something I would have written by hand  ;)
21:54 thundergnat Generated with Perl 6 SVG::Plot. Task now up: http://rosettacode.org/wiki/Plot_coordinate_pairs#Perl_6
21:54 fedaykin "Plot coordinate pairs - Rosetta Code" http://rldn.net/6cy
21:55 thundergnat \o/   Thanks again for the help.
21:55 Hypftier you're welcome. I'm knee-deep in SVG all the time these days, anyway ;)
22:31 mikemol BenBE: Looking at today's error.log file. I see a lot of "PHP Notice: Undefined offset:  3 in ...geshi.php on line 3383.
22:39 axisys left #rosettacode
22:46 axisys joined #rosettacode
22:50 TimToady thundergnat: what is @x     => ([@x]),  ???
22:52 thundergnat The x values for the x,y pairs. Or, at least, that is what it seems like. The documentation is a little sparse.
22:52 TimToady why @x for a pair key?
22:52 thundergnat um
22:54 TimToady also, pairs are supposed to be item context, so values => @y ought to pass @y in without the ([])
22:54 thundergnat Like I said, the docs are minimal , I just followed what the examples in the SVG::Plot module had and it seemed to work.
22:55 thundergnat I didn't actually write the module, just used it.
22:56 TimToady I suspect it actually ignored your x values, since they don't have a decent key, and guessed 0..9, and it just happened to work out the same :)
22:56 TimToady but don't have it here to test, alas
22:57 thundergnat Possible. I'll read the source a little more carefully and see what I should be doing there.
22:57 TimToady thanks
22:57 thundergnat https://github.com/moritz/svg-plot/blob/master/lib/SVG/Plot.pm
23:05 TimToady yes, you wanted labels => @x, but it defaults to that by accident
23:06 TimToady funny that they come out turned 90°
23:06 thundergnat Actually, I wanted x  => @x, then use plot(:xy-lines). What I have only worked by accident. :-/
23:07 TimToady okay
23:07 TimToady also don't really need the parens around the initializers at the top
23:07 thundergnat The 90° rotate is by design - so if the lables are long they don't collide.
23:07 TimToady ah
23:07 * TimToady is not a grapher  :)
23:08 * TimToady is glad that thundergnat++ is a grapher
23:08 thundergnat No really necessary for single digit lables but not worth overriding either.
23:08 thundergnat Not so much a grapher as a wannabe....
23:08 Hypftier Excel uses a 45° rotation ;)
23:09 Hypftier looks weird for single-digit labels, though, I guess.
23:20 thundergnat Hypftier: Sigh. Could I  impose on you to regen that file again with the text converted to paths? I uploaded a new version to reflect change generation code and it has the same thumbnail problem...
23:21 thundergnat Or maybe I should wait and let mikemol take a look at it when he has a chance.

| Channels | #rosettacode index | Today | | Search | Google Search | Plain-Text | summary