svn switch --relocate svn.openfoundry.org/pugs svn.pugscode.org/pugs/ | run.pugscode.org | spec.pugscode.org | paste: sial.org/pbot/perl6 | pugs.blogs.com
Set by avar on 16 November 2006.
00:04 polettix joined 00:09 mjk joined 00:15 whooosh joined, lambdabot joined 00:47 zgh joined 01:04 ssig33 joined 01:26 weinig is now known as weinig|bbl 01:27 lyokato joined
TimToady @tell Ovid It looks like junctions are working right to me. See S09:543 for description of autothreading. 02:29
lambdabot Consider it noted.
02:42 dmq joined 03:00 bonesss joined 03:16 weinig|bbl is now known as weinig 03:18 nothingmuch joined 03:20 weinig is now known as weinig|zZz 04:08 elmex_ joined 04:15 prism joined 04:29 mako132_ joined 05:06 bsb left 05:15 vanny joined 06:13 nipra joined 06:14 BooK joined 06:16 kisu joined 06:31 vanny left 06:49 iblechbot joined 07:06 trexy joined
trexy hi? 07:06
I just wanted to drop an idea into the meme pool ... 07:07
first a confession ...
I was once a Java programmer
which means using "this" all over the place
so I'm preparing to change to "self" --- per the synopses 07:08
while doing a global replace of this for self --- I realised both are 4 letters long 07:09
and then I wondered about a shorter version: me?
which kind of mirrors "my"
me-Ā»do_some_method() 07:10
but I was always taught to say "I" instead of "me"
i-Ā»wen_to_the_beach()
the problem with that is i --- is almost universally used in compsci as a loop iterator 07:11
hmmm .... then maybe capital I?
I.went_to_the_beach() 07:12
TimToady we abbreviate self to S and put an I in the middle so it's legal to say 07:13
$.went_to_the_beach()
trexy Ok ... that's another character less
:-)
so "the topic" is $.
the "I" 07:14
TimToady no, the topic is always $_
the "self" is not really "I"
trexy so the I is $.?
TimToady I is the programmer.
or maybe the lexical scope.
the "self" is really "yourself"
a method is a recipe given by the programmer to the object. 07:15
...now shoot yourself in the foot...
trexy ok ...
when you call a method on an object
it kind of exists though 07:16
but whenever you use this/self etc ... it always inside the object
TimToady sure, but it's just like a self-help book. 07:17
trexy that you look up from inside the object
so $. really performs this function anyway ---- so I think my problem is solved 07:18
a shorter version of this/self
TimToady we spent a lot of time thrashing this out several years ago... 07:19
trexy cool
TimToady you *can* have the current topic be self, but only by explicitly declaring your invocant as $_
for a while ./foo() was the self call, but it doesn't really work out right. 07:20
trexy ok
TimToady the sigil-as-self works to document the item/list/hash context nicely. 07:21
and keeping the dot in the middle means all the dot variants also work.
$.=foo $.*foo etc.
trexy cool
on a different note .... 07:23
TimToady G#?
trexy a Perl6 presentation at LPW last week demonstrated roles
I'm not sure if I got this right ... 07:24
07:24 ssig33 joined
TimToady that's okay, neither are we. :) 07:24
07:24 ofer1 joined
trexy but I think role can't hold a data structure 07:25
so no attributes per se - for the role?
TimToady 'course not, it's not an object.
however, it can have a generic attribute that gets instantiated
when the role is composed into a class
trexy ok ... but then if the role acts on some data --- it needs to specify what it wants? 07:26
TimToady by just calling the appropriate method?
$.foo is really a method call, btw
trexy the example given I think required a "does" to pull in the data structure 07:27
TimToady does is how you compose a role into a class, or into another role. 07:28
you can also use them more like ordinary mixins at run time. 07:29
but if it's something that's known at compile time, it's better to compose them then because you can detect collisions.
trexy sorry --- I just pulled up the slide
you use the "has" keyword to pull in the shared state 07:30
TimToady has is just the declarator for attributes 07:31
trexy OK ... this is what I'm talking about
sorry about the confusion
so if you declare a role on attributes --- you can say that the class "has" something the role needs 07:32
anyway the reason why brought this up --- is a member of the audience made want sounded like a good suggestion 07:33
if the role says ---- the class I get composed into needs .... "thing" 07:34
what about the word "have"? ... as in the class must "have" this attribute if the role is going to work? 07:35
TimToady The code already indicates what you need, generally.
if the role says $.foo then something must provide the foo method. 07:36
either with explicit "method foo" or by "has $.foo" or by inheritance or composition or delegations of something that provides the foo method.
trexy OK
TimToady so I don't see a need for an explicit extra declaration. 07:37
trexy the example given as a dog with 4 paws
has @paws
TimToady roles are more-or-less immutable, so they have to have the code when they're compiled.
so it's not like a role can defer something with naming it, generally.
the composition process is allowed to assume that all the methods it sees at class composition time are all that are availabe. 07:38
and issue warnings on missing things.
the warnings can be suppressed, which is a form of declaration, I suppose...
trexy Ok ... but I'm not sure I understand 07:39
if I declare a role for a dog class ---- lift_leg()
TimToady lift_leg() would be a method, not a role 07:40
well, not with that syntax...
$.lift_leg()
trexy ok .... I'm trying to think of a use case for roles and dogs
TimToady class Dog is Mammal does Pet {...} 07:41
trexy can't more that dogs lift their legs --- cats too?
ok Pet ... eats_dinner? 07:42
TimToady class Mammal is Quadraped does Legs {...}
well, Quadraped does Legs, maybe
trexy Legs lift_one?
TimToady the hierarchy starts breaking down when functions cut across... 07:43
but that's why we have roles.
but the Pet role is more like a role. 07:44
trexy indeed --- I can see that roles apply across the hierarchy --- which is great
TimToady leggedness is more an innate quality of Dog is Mammal is Animal
trexy OK... I'm just trying to come up with an example where your role needs data in the class like @legs / @paws etc.
TimToady well, that example is probably my fault. 07:45
how 'bout role Pet { has $tag; has $collar }
something associated with Pethood, not animalhood.
trexy sounds good
so this means that the composing class needs to have a collar? 07:46
TimToady no
trexy ok .. then I misunderstand
TimToady it means that Pet will make sure one is provided.
except has $collar would be private, you'd want has $.collar to declare an accessor to be public 07:47
trexy to allow the role to get to it
TimToady or write your own accessor in the role.
trexy OK 07:48
TimToady the role can access the private storage directly, but generally anyone outside the role will use the method.
inside $!collar is the actually storage location.
but you can't access that from outside.
trexy so I think the suggestion was simply: role Pet { have $tag; have $collar }
TimToady at least, not outside the class.
there's some debate whether the class should make a role's private data available to the rest of the class. 07:49
trexy hmmm .... it's tricky
TimToady well, that's a useless role, really, unless there are accessors.
which is why I should at least have put $.collar
trexy like this ... role Pet { have $.tag; have $.collar } ? 07:50
TimToady but then the have isn't buying you much over the has.
trexy so anything that plays the Pet role must have a tag and a collar 07:51
TimToady we proposed a different use for "have" dealing with turning closures into objects, so that would conflict too.
trexy I just thought I would pass on the suggestion
TimToady though it's kind of similar, in that "have $x" inside a closure would make a $.x attribute from any inherited lexical $x from outside the closure. 07:52
trexy it seemed to make sense when reading the role --- as it applied to the class
TimToady I agree that there is a natural tendency to take plurals as shared. 07:53
that's how we ended up with "our", after all.
trexy I like our, my etc
TimToady I do think that where "has" is expected, "have" looks a little too much alike.
trexy ok 07:54
TimToady I in fact missed your haves there for about 20 seconds...
and misread them as has.
trexy i'm sure with usage it will work out
TimToady anyway, if we need something declarative to do that, we'll certainly not hesitate to provide some kind of declaration, though perhaps not with "have". 07:55
adding new declarators is not supposed to be difficult in Perl 6...
trexy sure ... something that lets the programmer know what the role needs --- when it is re-used 07:56
TimToady yes, that's been our approach to a lot of this stuff, design what we can, and assume we'll tweak it where it doesn't quote work.
*quite*
trexy role Pet { needs $tag; needs $collar } 07:57
;-)
TimToady well, and the original Traits paper had something very like that.
though only with methods, not attributes. 07:58
trexy this would certainly put any role user on notice --- to use this role -- you need ...
TimToady the compiler already knows you've called $.tag and $.collar though. 07:59
(unless they're in an eval or something) 08:00
08:00 ssig33 joined
trexy I mainly thiinking from the programmer's perspective 08:00
TimToady well, comments have to be good for something.. :) 08:01
trexy "I need something to do this" 08:02
"what does this"
TimToady but maybe just something noopy: "exists $.tag;"
trexy ok ... there must exist a $.tag for the role to work 08:03
TimToady just some way to mention $.tag near the top is sufficient, I think.
"hasn't $.tag;" :) 08:04
trexy ok ... this will cue the programmer - if I'm going to use this role my class needs .... such and such
TimToady on the other hand, maybe there's some way for all participating roles to declare a shared attribute. 08:05
without any of them taking responsibility for actually creating it.
seems a little odd though.
trexy that's interesting
TimToady I think the standard position though is that you just call it $.foo from all the roles and force the class to "has" it. 08:06
if that's good enough most of the time, we probably don't want to clutter the works with additional declarators. 08:07
trexy hmmm ... then variables would be cast into role-space 08:08
TimToady In general it's just a lot safer to do all the interfaces with methods, since that lets you refactor the attribute out to a base class or role. 08:09
trexy yes ... and it can be hidden inside an object 08:10
TimToady so if you have a bunch of roles wanting to share an attribute, they probably all just pull in a single role that defines it, or delegates it, or whatever.
trexy so maybe conventionally speaking people will do this to make their role doable 08:11
TimToady we'll see how it all works out, or not...
trexy I'm personally really excited about it 08:12
TimToady the new metaobject protocol is about to be hooked into pugs, so maybe you'd like to help out with that over the next little while.
have you played with pugs at all? 08:13
08:13 buetow joined
trexy I'm hoping to help out with an IDE-like thingy 08:13
I've played with a pugs a bit
TimToady well, certainly an IDE needs to know all the metadata it can know. 08:14
have you got a pugs commit bit yet?
trexy indeed --- and I think a way of hypertextually traversing the OO structure is called for too ....
I note Stevan's smalltalk-esque class browser etc. 08:15
no commit bit yet ... but I would like to share this IDE-like thing at some point 08:17
TimToady if you send an email I can send you a commit bit. 08:18
trexy ok ... not sure what I would commit though? 08:19
TimToady anything you like. tests, docs, idea files, code 08:20
08:21 kisu joined
trexy I'm going to start the process of converting the IDE-like thing into Perl6 and once it looks reasonable donate it to the cause! 08:24
TimToady cool! 08:25
trexy best wishes to you and the pugs team 08:26
bye
TimToady thanks, good night.
zzz & 08:27
08:50 ssig33 joined 08:56 fayland joined 09:11 lyokato_ joined 09:12 elmex joined 09:19 buetow joined 09:26 devogon joined 09:31 ssig33 joined 09:41 frankg joined 10:01 andara joined 10:19 chris2 joined 10:35 ruoso joined 11:04 nothingmuch joined 11:17 pbuetow joined 11:21 ssig33_ joined 11:58 drbean joined 12:13 xpika joined 12:21 araujo joined 12:24 araujo joined 12:34 iblechbot joined 12:35 xpika left 12:50 mako132_ joined, pbuetow joined
jrockway so cross operators don't work yet? 13:12
?eval (1..10) X+X (10..1) 13:13
evalbot_r14929 Error: ā¤Unexpected "X"ā¤expecting operator
13:14 marmic joined 13:15 amv joined 13:20 dduncan left 13:21 ruz joined 14:04 iblechbot joined 14:16 gnuvince joined 14:48 chris2 joined
nothingmuch audreyt: ping 14:58
audreyt pong
nothingmuch i was wondering how MO is working out in pugsland 14:59
audreyt I made dispatch work for Str.reverse
otherwise still in deep tuit debt to touch that code 15:00
nothingmuch ah
nothingmuch will check back
how's life?
audreyt extremely saturated 15:01
doing, generally, this: xrl.us/tx6e
15:05 iblechbot_ joined
nothingmuch has been doing that too, to some extent 15:10
i am a naughty module author now
(i have some known bugs which I haven't fixed yet)
but i am getting a lot of hiking done ;-)
audreyt cool :) 15:11
nothingmuch freezing, in fact
twas -5 in the desert the night before last
nothingmuch will upload pics in a sec
15:12 awwaiid joined
nothingmuch hola brock 15:12
gallery.woobling.org/main.php?g2_itemId=4535 15:14
lambdabot Title: Hiking in the Desert
15:19 awwaiid joined
jrockway nothingmuch: looks like it was a fun trip; very pretty 15:19
nothingmuch aye
jrockway nothingmuch: any HDR pictures on your site?
nothingmuch more photos from Henryk and Stan are pending
from the first 2 days 15:20
nope
nothingmuch hasn't felt the need to take one since having learned that there is software for that
kolibrie what's up with the poles? gallery.woobling.org/main.php?g2_itemId=4594 15:23
lambdabot Title: IMG_1954.jpg
15:25 awwaiid joined 15:29 weinig|zZz is now known as weinig
kolibrie nothingmuch hikes up and skiis down? 15:37
nothingmuch kolibrie: sooon sooooooon 15:38
jrockway i think the premise behind the use of poles is so you can use your upper body to help you climb
nothingmuch is buying a splitboard and going to california
jrockway or maybe nothingmuch just wants to look cool in pictures
nothingmuch but as for the desert hiking;
if you use the poles correctly (clkao++ for improving my technique)
then you can go faster
and also you get to save your knees on the down hill (my main concern) 15:39
kolibrie normally carries children, rather than poles, which significantly slow hiking speed
nothingmuch and you can get up without needing to do weird balance tricks
(assuming a heavy backpack is making it difficult... c.f. the aforementioned picture)
kolibrie it is a cool picture 15:40
nothingmuch yeah, i don't look as ugly as always ;-)
nothingmuch is trying to upload a large panorama
but gallery is being a pain
kolibrie nothingmuch: who is the girl in gallery.woobling.org/main.php?g2_itemId=4051 15:41
lambdabot Title: DSC_3222.jpg
nothingmuch neta
foaf
we were the only non drunks at that party
;-) 15:42
kolibrie :)
nothingmuch well... partly
15:56 bonesss joined
svnbot6 r14930 | andara++ | [runpugs] 15:59
r14930 | andara++ | -Now with preloaded pugs sessions for faster startup.
15:59 hexmode joined 16:01 nothingmuch_ joined
pasteling "kolibrie" at 66.239.158.2 pasted "how to I push values onto an array in regex" (40 lines, 1K) at sial.org/pbot/21891 16:03
kolibrie s/to/do/ 16:04
16:11 nipra joined
nothingmuch_ gallery.woobling.org/v/Family/album...o.jpg.html 16:11
wow, that was difficult =(
kolibrie that's a pretty nice picture 16:12
andara yes, very nice! 16:13
lambdabot Title: pano, tinyurl.com/api-create.php?url=http...t;BODY>
andara nothingmuch_: where do the shadowy figures come from? 16:14
nothingmuch_ the panorama blending 16:16
they are those two people
and Steffi is the one ont he right... she is also slightly transparent 16:17
she was the oone who stayed with me for the whole 4 days
16:25 buetow joined 16:27 weinig is now known as weinig|bbl 16:28 kanru joined 16:36 frederico joined 16:41 buetow joined 16:43 fglock joined
fglock hi 16:44
kolibrie fglock: hi 16:45
fglock: I have a question - I'll paste it in a minute
fglock ok
I've been busy with a workflow app, I'm more or less back on schedule now 16:46
I've got mp6-mo started, but it still looks very unclean
kolibrie is using PCR/v6.pm for $work
fglock oh, nice! 16:47
pasteling "kolibrie" at 66.239.158.2 pasted "how do I read from this array returned from a regex?" (47 lines, 1.2K) at sial.org/pbot/21892 16:50
16:52 bcorn joined 16:57 orafu joined, andara left
fglock kolibrie: the regex is not returning an array for me 17:01
kolibrie hmm 17:02
pasteling "kolibrie" at 66.239.158.2 pasted "fglock: my output" (15 lines, 356B) at sial.org/pbot/21893 17:03
fglock same here - did you try to print $match.perl (trying here) 17:04
it looks like the captures are nested (not in the return object) 17:06
17:06 bcorn joined
kolibrie it looks like the array should be available as @$match and @($match<numbers>) 17:07
I think
fglock kolibrie: you probably need to use return blocks 17:08
see the output of $match.perl
kolibrie I am using return blocks
fglock you are not returning the recursive result of <numbers> 17:09
from inside <numbers> 17:10
kolibrie { return [ $$<number>, @( $$<numbers> ) ] }
fglock something like that
kolibrie that's in there
uggh, my wrap was off, so the paste is incomplete 17:12
fglock ah, ok
pasteling "kolibrie" at 66.239.158.2 pasted "trying to read array returned from regex" (49 lines, 1.3K) at sial.org/pbot/21894 17:13
fglock this works: for @$$match -> $object { say $object }; 17:18
kolibrie tries
fglock not sure if it's a bug
kolibrie ok, that works here, too 17:19
fglock: what if I want to return the whole submatch object, not just the string value? 17:22
return [ $<number> ] does not seem to work
return [ $$/ ] maybe? 17:23
no, probably not...
fglock do you mean $$<number> ? 17:24
for the object returned by the subcapture
kolibrie right now the array returned from the subcapture is ['one', 'two', ...] 17:25
what if I want it it be [$submatch1, $submatch2, ...]
for @$$match -> $object { say $object<name> }; 17:26
or <number> or whatever it is
fglock you are using 'return [ $$<number> ]' - try 'return [ $<number> ]' 17:27
but $$<numbers> is ok 17:28
kolibrie ah, yep, that works 17:29
I was switching $$<numbers> too
but that makes sense to leave it $$<numbers>, I think
fglock $$<numbers> is the array under construction 17:30
while $<number> is the new item
kolibrie right
kolibrie is trying to keep everything straight in his brain 17:31
fglock I wonder if using method names would help, like '$<numbers>.thing' instead of '$$<numbers>' 17:34
kolibrie do you have an example? (I'm intregued, but lost) 17:36
fglock no, I'm just thinking if it would help if you could have an alternate, more verbose syntax 17:39
that would be more readable, maybe 17:40
kolibrie well, really, the whole perl 6 regex syntax is the alternate. I'm just getting used to it
plus, I'm trying to make a base grammar to hold all the tricky stuff, and have subclasses of that grammar that other people can write and maintain 17:41
17:45 justatheory joined 18:21 diotalevi joined 18:28 bcorn_ joined 18:32 mr_ank joined 18:33 fglock joined
kolibrie when I do this in a 'for' loop, I can see the values, but I can't seem to get the values into an array 18:41
for @$$match -> $object { say $object<name> }; # works
my @list = map { $_<name> }, @$$match; for @list -> $name { say "name: " ~ $name }; # prints name: ARRAY(0x8c47038)
avar ?eval 1 18:43
evalbot_r14930 1
avar kolibrie: use evalbot
fglock kolibrie: not sure if map works properly, I think there was some Data::Bind or arrayref related bug 18:47
in v6.pm
kolibrie fglock: any other ways to get the data in an array?
avar: works properly in pugs
18:48 rindolf joined
rindolf Hi all. 18:48
I have a question about perl6: if every block is a closure, how come it gets executed? 18:49
fglock kolibrie: lib/Pugs/Grammar/Rule2.pm still uses 'use v5; map ...'
rindolf Hi fglock 18:50
kolibrie fglock: hmm. well, at least there's a workaround
integral there's a rule covering that case , rindolf
rindolf fglock: happy Hanukkah/xmas.
fglock rindolf: it just executes immediately
rindolf: hag sameach
rindolf fglock: todah.
fglock: but sub { ... } in Perl 5 doesn't execute immediately. 18:51
eval: print "5"; sub { print "6"; } ; print "7"
buubot rindolf: 5 7 1
fglock it does not execute immediately in p6, either
only bare blocks 18:52
rindolf fglock: ah.
kolibrie fglock: this seems to work: my @list; for @$$match -> $object { push @list, $object<name> }; 18:57
it just takes more lines 18:58
19:05 nothingmuch_ is now known as nothingmuch 19:07 penk joined
ofer0 eval: print 5; sub { print 6 }->(); print 7 19:09
buubot ofer0: 5 6 7 1
ofer0 just wanted to make sure
gnuvince ?eval sub foo { return "x" }() 19:13
evalbot_r14930 ()
gnuvince ?eval sub { return "x" }()
evalbot_r14930 "x"
19:20 Aankhen`` joined
kolibrie yay! now my grammar is behaving! 19:33
fglock: thank you very much for all your help today 19:34
(and in the past, too)
fglock np 19:39
19:41 justatheory joined 19:45 ozo joined
DebolazX YAML::RPC would be nice. 19:50
20:19 nipra joined 20:25 Ovid joined 20:26 thepler joined
Ovid How do I count how many keys are in an array without using a temporary array? Various permutations of one liners keep giving me "Cannot cast from vlist" 20:30
lambdabot Ovid: You have 1 new message. '/msg lambdabot @messages' to read it.
Ovid is %unique.keys.elems, 6, '... and they should all be unique numbers';
TimToady ?eval my %foo = (a => 1, b => 2, c => 3); say +%foo 20:34
evalbot_r14930 OUTPUT[3ā¤] Bool::True
Ovid ?eval my %unique = map { $_ => 1 }, 1.. 6; %unique.perl.say; 20:37
evalbot_r14930 Error: Cannot cast from VList [VInt 1,VInt 2,VInt 3,VInt 4,VInt 5,VInt 6] to Pugs.AST.Internals.VCode (VCode)
Ovid I think I'm misunderstanding something. 20:39
TimToady ?eval my %unique = map { return $_ => 1 }, 1 .. 6; %unique.perl.say 20:40
evalbot_r14930 Error: Cannot cast from VUndef to Pugs.AST.Internals.VCode (VCode) 20:41
20:41 araujo_ joined
TimToady ?eval my %unique = map sub { return $_ => 1 }, 1 .. 6; %unique.perl.say 20:42
evalbot_r14930 OUTPUT[{("1" => 1), ("2" => 1), ("3" => 1), ("4" => 1), ("5" => 1), ("6" => 1)}ā¤] Bool::True
TimToady seems to be overzealously turning {...} into hash composer
20:43 araujo joined
Ovid Ah, I see. Time to add a test. Should known failing tests kill a *.t program? I don't know what's intended there. 20:44
allbery_b use eval?
Ovid I've seen eval used for things which are not implemented yet (though I haven't gone through the test suite too thoroughly), but adding tons of evals everywhere sounds like something which would be a pain to remove later on when it's the real Perl 6 test suite. 20:45
TimToady they don't really need to be removed, esp since other implementations may need them later 20:47
Ovid OK. Thanks.
TimToady on the other hand, until we're getting close to another release, it doesn't really matter much if the whole .t blows 20:48
gaal I doubt other implementations will share pugs' bug battlin' biography :)
(hello1)
heh, s/1/!/
Ovid On another note, I've converted the "99 Problems" into separate test files. Are they OK to commit? If so, examples or (likely repetitive) .t programs?
gaal sure, commit 20:49
hmm, I'd say examples/
TimToady examples will autotest at least the compilation of them. 20:50
Ovid OK
TimToady but if they're already TAP format, put 'em into t/ 20:53
that is t/examples/ 20:54
or maybe t/general, since t/examples is about testing examples/ 20:55
or put 'em in examples with something special in t/examples to run 'em. 20:56
Ovid Hmm, I could put them in t/examples/99problems/. How does that sound? They are proper tests: 20:57
use v6-alpha;
use Test;
plan 1;
# P01 (*) Find the last box of a list.
#
# Example:
# * (my-last '(a b c d))
# (D)
is <a b c d>.[-1], 'd', 'Find the last box of a list.';
(I shoulda used nopaste)
dmq waves hello 20:59
Ovid waves back.
TimToady t/e/99 sounds fine 21:05
probably want to include a link to the original 99, so people can figure out what "box" means. 21:07
but with your own dir you can put a README easily enough 21:09
Ovid I put a README in there and just committed. Hopefully people will try to solve some of them. 21:11
svnbot6 r14931 | Ovid++ | Added the "99 Problems". Currently I've only "solved" the first 24. See the
r14931 | Ovid++ | README for more information.
21:17 Odin- joined 21:22 wamiks joined
jrockway Ovid: i replied to your email to perl6-users, but it appears to have been lost 21:39
basically the issue is, what does say(1&2&3) really mean?
say 1, then say 2, then say 3?
or say "1&2&3"
Ovid No, I got the email. However, I'm still concerned about the original function which took a junction as an argument, didn't use it, returned a scalar which should have been evaluated in a numeric context ($count++) and yet still appeared to return a junction. 21:41
TimToady you didn't read my lambdabot message 21:43
please see S09:543
you're not allowed to pass a junction to a routine that isn't expecting it. 21:44
instead, such routines are autothreaded. 21:45
Ovid Where's S09:543? I've been looking in perlcabal.org/syn/S09.html#Junctions 21:47
lambdabot Title: S09
Ovid Is that the wrong spot?
(I know you've sent the link before and my apologies if I've forgotten)
TimToady that's the right spot: In any scalar context not expecting a junction of
values, a junction produces automatic parallelization of the algorithm.
Str is not a Junction 21:48
Ovid OK. Thanks. I'll catch on sooner or later.
TimToady otherwise we'll have all sorts of routines getting surprised by values that are simultaneously true and false. 21:49
21:53 scw joined
Ovid Is the following a legal syntax legal? rafb.net/paste/results/YNsbbg66.html 21:59
buubot The paste YNsbbg66 has been copied to erxz.com/pb/669
Ovid Hmm, I typed the sentence, went and pasted the code and then finished typing the sentence. I shouldn't do that. 22:00
TimToady s/subtype/subset/ 22:01
but why not just use UInt? 22:02
Quibble: I think most people would consider 0 to be neither Positive nor Negative. 22:03
Ovid Does an unsigned integer include 0?
(I don't know C terribly well) 22:04
TimToady and you probably want to return List rather than Array
certainly
Ovid OK. Thanks.
So the Positive::Int works better for that. 22:05
TimToady but you defined it to include 0 too
Ovid Oops.
www.oreillynet.com/onlamp/blog/2006...erl_6.html 22:17
lambdabot Title: 99 Problems in Perl 6 - O&#039;Reilly ONLamp Blog, tinyurl.com/w763k
Ovid Feel free to post any corrections.
TimToady looks good 22:20
22:22 dduncan joined
Ovid sports a miniskirt and pom-poms online. 22:22
dduncan is there a picture?
22:23 weinig|bbl is now known as weinig
Ovid www.oreillynet.com/onlamp/blog/2006...erl_6.html 22:23
lambdabot Title: 99 Problems in Perl 6 - O&#039;Reilly ONLamp Blog, tinyurl.com/w763k
stevan_ Perl 6 has only 99 problems !
we are almost finished then !!!
:P
Ovid Actually, my "secret Santa" gift at work was purple wings, a purple feather boa, a wand with a star on top and a pink thong. At least one coworker has a picture. 22:24
(I was wearing clothes underneath all of that, though)
I'm just amazed at how verbose all of the non-Perl solutions were. Either the online solutions I found were poorly written or Perl 6 has done a great job at solving many common programming problems. 22:26
dduncan speaking of problems remaining, check this out: joyoftech.com/joyoftech/joyarchives/903.html
lambdabot Title: The Joy of Tech comic... laughter is the best tech support.
stevan_ Ovid: well the perl 6 version uses Juntions,.. which the other languages dont have 22:27
Ovid Oops. There was a bug in the Prolog solution. It's fixed now.
stevan_ I would be interested to see a non-Junction verison and how it compares
jrockway ?eval say (1|2)
evalbot_r14931 OUTPUT[any(VInt 1,VInt 2)ā¤] Bool::True
jrockway that shouldn't randomly select between "say 1" or "say 2"? 22:28
Ovid Hmm, the Lisp version had the same problem. Just fixed that, too. 22:29
TimToady ?eval say (1|2).pick
evalbot_r14931 OUTPUT[2ā¤] Bool::True
Ovid stevan: my Perl 6 version used a junction? Does .pick use that under the hood or something? 22:30
jrockway TimToady: i see. that looks like what's been going back and forth in here over the last few days 22:31
stevan_ Ovid: IIRC, pick is related to Junctions,.. but hmm... maybe not
jrockway is slowly starting to understand a language that only partially exists :)
22:31 stevan_ is now known as stevan
TimToady likewise 22:31
jrockway with the usual choices in langauges, you can type something in to see if it's right or not. with perl6, you have to decide whether you're right or pugs is right :) 22:32
fun
TimToady it is, hopefully, a convergent process 22:33
stevan Ovid: according to S29, it is a "method" of Lists/Arrays
TimToady it also happens to coerce a junction to a list 22:34
stevan ah,..thats where I was confused then :)
TimToady hmm.
?eval any(1..5).pick(*) 22:35
evalbot_r14931 Error: pick not defined: VJunc any(VInt 1,VInt 2,VInt 3,VInt 4,VInt 5)
TimToady ?eval (1..5).pick(*)
evalbot_r14931 (1, 2, 5, 3, 4)
22:35 gnuvince joined
TimToady looks like luqui only made pick(*) work for lists/arrays, not junctions. 22:35
?eval (1..5).values 22:36
evalbot_r14931 (1, 2, 3, 4, 5)
TimToady ?eval any(1..5).values
evalbot_r14931 (1, 2, 3, 4, 5)
Ovid The current implementation doesn't scale well, either.
TreyHarris hey, does anyone know somewhere i can see the complete list of funny symbols the Mac uses to represent the functional keys on the keyboard? cloverleaf and caret and that funny microswitch symbol for option i've got down, but some of the odder ones confuse me. googling for "mac keyboard symbols" and other such keywords is decidedly unhelpful so far
Ovid ?eval (1 .. 10000).pick(9999).perl.say
evalbot_r14931 pugs: out of memory (requested 1048576 bytes)
TimToady heh
Ovid I think a better strategy would be to shuffle the list and take the first $count elements, but I don't know how to write the Haskell :( 22:37
lumi TreyHarris: macbiblioblog.blogspot.com/2005/05/...mbols.html looks useful
lambdabot Title: The Macintosh Biblioblog: Special Key Symbols, tinyurl.com/y8cev2
TimToady when I say "uni clover" I don't find anything, so if it's in Unicode it's got a different name. 22:38
lumi "PLACE OF INTEREST SIGN"? 22:39
TimToady PLACE OF INTEREST SIGN
TreyHarris TimToady: it's the place of inte.... yes, beat me to the punch 22:40
TimToady lumi beat us both, by a couple microseconds... 22:41
TreyHarris none of the pages i've found say what the symbol in this image is: ibiblio.org/harris/whats-this-symbol.png 22:43
TimToady hmm, whether you want to presort the shuffle depends on how many you want
TreyHarris next to the bottom... "Show sticky desktop overlay pager". option-something, but what?
jrockway Ovid: what about something like f x = [y | y <- x, y < rand xmax ]
lumi TreyHarris: Tab
TreyHarris lumi: hah, so it is
thanks :) 22:44
jrockway actually, not what i meant...
back to thinking before i type :/
Ovid jrockway: does that guarantee unique elements?
TimToady āŒ„
option (alt, alternative)
U+2325
according to the other page.
jrockway Ovid: it does, but it doesn't do anything useful
it gives you "a few" elements
Ovid Er, is that Haskell, I assume? 22:45
jrockway yeah. perl5 equiv: @few = grep { $_ < rand } @many 22:46
TimToady assign a random num to each element, then find lowest N, then sort those in order of randoms, unless N is big, in which case better to sort first. 22:47
Ovid I don't know Haskell, I fear. (and Lisp and Prolog are languages I only know a few "words" in)
jrockway the way to not not know haskell is to learn it 22:48
i'm enjoying it so far
TimToady as a limiting case, it'd be stupid to sort them all for .pick(1)
jrockway however i still don't understand darcs or pugs
TimToady: it would be nice to not sort at all
TimToady how do you randomize them?
Ovid TimToady, what about the unlikely event that two random numbers are the same? You still have to test for uniqueness.
jrockway i.e. pick 3 == @list[rand @list, rand @list, rand @list]
TimToady no, that's with replacement 22:49
jrockway Ovid: if you use an unstable sort then you can let the other random numbers randomize the ordering of "same" elements
TimToady pick is without replacement
Ovid Ah. OK.
TimToady however, for a small N @list[rand @list] and throw back dups is pretty fast. 22:50
very fast for N==1
since by definition there's no dups
but that would be really slow for .pick(*) 22:51
though not as slow as the World's Slowest Sort Algorithm.
Ovid I would think that .pick(*) would be an edge case. Shuffle and return. 22:52
jrockway it would be O(N) right
TimToady somewhere in the middle there's a breakeven, or a 3rd algorithm.
Ovid Incidentally, pursuant to use.perl.org/~Ovid/journal/31970, it would be wonderful to have a special syntax saying "all subroutine arguments are 'is copy'" 22:53
lambdabot Title: Journal of Ovid (2709)
TimToady get close to the right number with one probabalistic pass, then add or subtract a few to make it exact.
jrockway that idea i like 22:54
Ovid I wouldn't always use it, but Aristotle made an interesting point about most Perl programmers defaulting to copies instead of aliases.
jrockway Ovid: probably not by conscious choice
i.e my $foo = shift; my $bar = shift;
they make copies beacuse it's easier to refer to "foo" than "$_[0]" 22:55
TimToady "autocopy if body contains mutator, ref otherwise"?
Ovid jrockway, that's likely true, and I certainly wouldn't want to force "is copy" on everyone, but the more I work through the 99 problems, the more I find it an annoyance.
jrockway that's fair
Ovid TimToady: I like that idea, though I wonder how it would play out in practice? I can't think of how it would hurt since arguments are read-only by default, but since we change the meaning of arguments by the code following them, I wonder what "action at a distance" side-effects might crop up. 22:56
TimToady esp with eval "" 22:57
but you have to detect readonly violations anyway
so maybe it can be sidetracked into autocopying instead.
really, we're probably discussing COW proxies here. 22:58
Ovid On the other hand, since "copy if mutator" would be such an extremely handy default, I wonder which would cause less grief? :)
jrockway what would be wrong with good-old-copy-on-write
Ovid The Dutch call this "harm reduction". 22:59
jrockway it makes reads quick, and writes sane
Ovid This is Perl 6 on drugs (sorry if that's too obscure)
jrockway although there's the possibility that you want to modify the arguments
Ovid You could force it with "is alias"
jrockway reducing harm is always good
TimToady that's what "is rw" means
Ovid Oh, duh/
TimToady I wonder what percentage of real subs will want to modifiy their args... 23:01
Ovid I'm not sure. All I know is that I kept hitting that with "99 Problems", but perhaps those aren't terribly representative. Perhaps this is a minicpan/ppi problem? 23:02
jnthn A related-ish question: do lower-cased types like int, num and so on automatically get is copy semantics since they aren't reference types.
Tene add a popup box whenever you use a sub to ask "do you want alias or copy?"
pasteling "stevan" at 71.234.68.135 pasted "Lotto function in OCaml" (14 lines, 475B) at sial.org/pbot/21906
jnthn s/./?
TimToady the nice thing about defaulting to readonly is that you don't have to commit to autoboxing int and num. 23:03
jnthn You could commit to not autoboxing them, but I guess other lowercase types like str are really references under the hood so it all kinda breaks down a bit... 23:04
Ovid I guess that's one question that minicpan/ppi can't answer.
jrockway i think subs that modify their arguments are not the usual case
the only Real Module i've ever used that does that is BerkeleyDB
and it's an insane module
success == 0, failure == !0
so you write $db->get_something($key, $value) and die "failed!" 23:05
Ovid stevan: post your OCaml as a response to the ORA post.
(please?)
jrockway (and you get the value of key inside $value)
TimToady well, it's only insane because they flipped from interesting values of success to interesting values of failure without preserving interesting values of success. :)
jrockway it would be nice if they just threw the exception for me :) 23:06
TimToady exceptions are by definition too interesting.
stevan Ovid: posted
Ovid The only thing I *like* which modifies it's arguments is trim(). chomp() is another common example, but I don't care for that syntax (oh, and open() alters its arguments, but that syntax is changing anyway)
TimToady well, when I said "modifies it arguments" I was really referring to "is copy"
jrockway Ovid: i have always hated the chomp-modification thing
Ovid jrockway: careful! Exceptions should be used very, very sparingly. 23:07
jrockway Ovid: like for... exceptional... cases?
TimToady Perl 6 has lazy exceptions.
Ovid Well, if we have COW for arguments, exceptions aren't needed. Or is that now what you meant?
23:08 Psyche^ joined
Ovid Exceptions should be used in such a way that you can remove all of them from your program and the program still runs if nothing goes wrong. 23:08
TimToady COW doesn't have much to do with exceptions.
jrockway Ovid: yes
svnbot6 r14932 | book++ | typos
Ovid Agreed, but I thought jrockway meant throw an exception if one tried to modify an aliased argument. Did I misunderstand?
jrockway yes 23:09
i was complaining about the berkeleydb interface :)
offtopic, sorry :(
Ovid Oh.
TimToady I'd rather catch the error at compile time.
23:09 autark joined
TimToady the problem with defaulting to COW is that the code will assume you want "is copy" rather than "is rw". 23:09
it will just silently fail to backpropagate
so I still think readonly is the sanest default. 23:10
perhaps "is copy" needs huffmanizing.
Ovid Thanks book!
jrockway i'm thinking of this case: sub foo ($arg) { say $arg; $arg = 3; say $arg; }
i.e. reusing the variable
TimToady technically illegal right now. 23:11
jrockway not really good code, but people do it
fine
Ovid huffmanizing++
jrockway better example is sub foo ($arg) { say $arg++ while($arg < 100) } 23:12
i don't see a reason to prohibit that, but it could be made illegal by default
TimToady which it is
Ovid Yeah, I see that sort of stuff all the time (I probably write it, too)
jrockway yeah, it's not the worst piece of code ever written 23:13
Ovid My rotten programming is all between us, right? :)
TimToady .say for $arg .. ^100
jrockway Ovid: i'm going to go to the bookstore and insert a copy of this transcript in your book :)
Ovid chromatic's book! O'Reilly offered me a space on the cover and I wasn't so stupid as to say 'no' 23:14
jrockway so there are three cases: pass an arg and never modify it (ro), pass an arg and modify it, but don't change it outside the lexical scope (my $foo = shift), and then $_[xx]-style aliasing
the middle case can be eliminiated by rethinking your code, of course 23:15
Ovid (Damian also deserved a place there on the cover. My stuff was just random tidbits, but enough to get me noticed)
jrockway ?eval sub foo($arg){ $arg++ }; foo(10); 23:16
evalbot_r14932 Error: Can't modify constant item: VInt 10
jrockway i'm liking the current behavior
optimizes for speed, since no copy is ever necessary
TimToady ?eval my $x = 42; sub foo($arg){ $arg++ }; foo($x); say $x 23:17
evalbot_r14932 Error: Can't modify constant item: VRef <Scalar:0xb68d5dcc>
jrockway ah, yes
TimToady jrockway: that was the idea
Ovid I can understand a universal optimization. I'd still like the huffmanization of "is copy" since I keep hitting it. 23:18
TimToady let me sleep on it during the incipient nap attack...
jrockway sub (+$arg) { ... }
i also need a nap :) 23:19
Ovid: could you nopaste a place where you want an "is copy"
Ovid jrockway: that looks clean, but I can't say if it's good or bad since I don't have enough P6 knowledge.
jrockway "is copy" confuses me because i have narrowed things down in my mind to "is rw" and "is ro"
is ro is the default, and is rw is an alias... right?
hence the beautiful php syntax foo (&$bar) would make $bar an alias 23:20
TimToady rw requires an lvalue. ref merely requires an object that might fail at run-time.
Ovid Sure, but first: ack 'is copy' t/examples/99problems/
jrockway ack? 23:21
TimToady a recursive grep
jrockway got it
Ovid See App::Ack on the cpan.
jrockway "look for all instances of 'is copy' in my examples"
yeah, i use ack
however i don't verb it :) 23:22
Ovid is copy: rafb.net/paste/results/IkBy6f44.html
buubot The paste IkBy6f44 has been copied to erxz.com/pb/670
TimToady how many of those would go away with a truly functional solution?
jrockway ie perl6 a purely functional language?
TimToady no, but "is copy" would encourage people in that direction.
:P
Ovid TimToady: I'd like to see counter-examples -- you have commit rights, yes? :) -- but I suspect most people don't think that way. 23:23
TimToady well, my nested gathers was already one such.
Ovid It was elegant. It was also longer code. I often find that gather/take is easier to read for beginners, but is longer code (hmm, that sounded a bit odd) 23:24
23:24 Psyche^ is now known as Patterner
TimToady mostly only because gather still requires a block 23:24
and take doesn't work en passant yet.
23:25 weinig is now known as weinig|away, weinig|away is now known as weinig
Ovid I think the fact that it's not a loop should be the biggest win (IMHO) 23:25
Actually, going back and reading things, your longer gather/take example is much easier to read than my example, though Aristotle (aka, edge_walker), shows an "easier to read" map in this thread: publius-ovidius.livejournal.com/219...html?nc=12 23:27
lambdabot Title: publius_ovidius: Pleasant pre-Christmas Evenings
TimToady sub group4 ($a) { 23:28
gather while @$a {
take [
gather loop (my $h = $a[0]; @$a and $h eq $a[0]; take shift $a) {}
]
}
Ovid Or I guess that "easier to read" is purely subjective.
TimToady }
hmm, that supposed to be |$a
since you can shift the capture to get its values. 23:29
Ovid OK, it's late here and I have to hit the hay. Talk to everyone later.
TimToady night
zzz & 23:30
23:31 larsen_ joined 23:32 weinig is now known as weinig|away