Perl 6 - the future is here, just unevenly distributed

IRC log for #perl6, 2006-11-24

Perl 6 | Reference Documentation | Rakudo

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

All times shown according to UTC.

Time Nick Message
00:08 mjk joined perl6
00:10 * dmq looks in
00:11 * buetow looks out :)
00:11 gnuvince` joined perl6
00:12 * eviltwin_b looks aside
00:12 gnuvince joined perl6
00:29 GabrielVieira2 is now known as GabrielVieira
00:30 nekokak joined perl6
00:34 bonesss joined perl6
00:44 bonesss joined perl6
00:51 bsb joined perl6
00:55 weirdo joined perl6
00:55 weirdo hello
00:55 weirdo will operator overloading be possible with perl6?
00:57 Juerd Yes!
00:57 Juerd You can even invent your own operators, so you don't have to overload. (As overloading can be dangerous)
00:57 weirdo i'd personally love to make $string[4 .. 6] = 42; work
00:58 weirdo i was hooked on ruby, but its scarce in modules
00:58 weirdo its curses module is fubar :/
00:59 weirdo ruby had a certain influence on me - i discovered sub closures and anon subs in perl
00:59 weirdo now i can't program without them :-)
01:01 Juerd Heh
01:01 Juerd Good for you :)
01:01 gnuvince ?eval my $s = "Hello"; substr($s, 0, 2) = 42; $s
01:01 evalbot_r14838 is now known as evalbot_r14842
01:01 evalbot_r14842 \"42llo"
01:02 weirdo gnuvince, substr is long and hard to type
01:02 gnuvince weirdo: I don't recall seeing any array-indexing type of syntax for strings.
01:02 weirdo including "," arg separator and parens
01:02 weirdo gnuvince, ruby has it! :-) all kinds of
01:03 gnuvince in Ruby, String is an Enumerable IIRC
01:03 weirdo str[1 .. 3] = "foo" # 2nd arg is index
01:03 gnuvince So it has #[], #[]= et al.
01:03 weirdo str[1 ... 3] = "foo" # 2nd arg is relative index
01:03 weirdo will there be a switch statement?
01:04 gnuvince On steroids, yes.
01:04 gnuvince It will be called given/when
01:04 weirdo oh. the one from Switch.pm! :-)
01:04 gnuvince http://perlcabal.org/syn/S​04.html#Switch_statements
01:05 lambdabot Title: S04, http://tinyurl.com/y5beho
01:05 weirdo will 'if' be a statement, so i could do '$val = if 1; 1; else 2; ?
01:05 gnuvince statement.
01:05 weirdo sorry for all of these questions. i just got back to perl after a while of ruby and i'd love to see a release of perl6 :-)
01:06 gnuvince weirdo: get pugs :)
01:06 weirdo does it cover all of perl6's specs?
01:06 gnuvince also, send me your email address in private message, I'll hook you up with a commit access
01:06 gnuvince Not all of it
01:11 weirdo is there a pugs cvs logs mailing list?
01:16 neonoen joined perl6
01:23 kanru joined perl6
01:37 jferrero joined perl6
01:41 fayland joined perl6
01:55 H0LE joined perl6
01:56 bonesss joined perl6
02:07 BooK joined perl6
02:07 nipotaway is now known as nipotan
02:09 bonesss joined perl6
02:19 Psyche^ joined perl6
02:20 yhsuan joined perl6
02:20 bonesss joined perl6
02:27 Psyche^ is now known as Patterner
02:31 dmq joined perl6
02:59 phpError joined perl6
02:59 ingy seen audreyt
02:59 jabbot ingy: audreyt was seen 3 days 14 hours 40 minutes 4 seconds ago
03:06 bonesss joined perl6
03:13 bonesss joined perl6
03:28 phpError joined perl6
03:33 ashleyb joined perl6
04:23 vel joined perl6
05:16 kanru joined perl6
05:22 nekokak_ joined perl6
05:44 phpError joined perl6
05:44 agentzh joined perl6
05:45 agentzh seen audreyt
05:45 jabbot agentzh: audreyt was seen 3 days 17 hours 25 minutes 30 seconds ago
05:47 agentzh @tell audreyt is there a way to configure YAML::Syck not to escape chinese characters (such as those in GB2312) just as YAML? escaping leads to terrible YAML readability imho. thank you. :)
05:47 lambdabot Consider it noted.
06:10 audreyt @tell agentzh use utf8 and $YAML::Syck::ImplicitUnicode :) otherwise no, there's no easy way
06:10 lambdabot Consider it noted.
06:15 BooK_ joined perl6
06:41 weirdo i wonder if operator overloading would be supported if $arr[0] wouldn't be changed to @arr[0]
06:42 rafl joined perl6
06:45 audreyt how does those two relate?
06:45 lambdabot audreyt: You have 4 new messages. '/msg lambdabot @messages' to read them.
06:54 offby1 audreyt: saw your talk at Amazon from last month.  Enthralling
06:55 audreyt video? or you were there?
06:55 offby1 video
06:55 offby1 bootlegged :-)
06:56 audreyt oooh. want!
06:56 audreyt upload it somewhere? I hear video uploading sites are plenty these days
06:57 offby1 I got the impression that it wasn't supposed to be broadcast, so ...
06:57 offby1 I've been unable to find documentation for (whatever the p6 equivalent is of) I/O layers.  Is there any?
06:57 audreyt I certainly would like it to be broadcast...
06:57 audreyt offby1: maybe ask @amazon.com source to see if I can make it available under CC license?
06:57 offby1 anyway I don't have it.  But if you want you could beg on the SPUG mailing list (Seattle PUG); one of the guys there has it
06:58 offby1 that would be the guy on SPUG.  I'll ask
06:58 audreyt TreyHarris: can we get my amazon talk video published, or at least smuggle me a copy? :)
06:58 audreyt offby1: k, thanks!
06:58 audreyt I need to run soon
06:59 offby1 oh, is TreyHarris a SPUG guy?  It was my first meeting and I didn't get any names
06:59 audreyt he invited me to amazon I think
07:01 offby1 composing mail now
07:01 audreyt danke
07:01 audreyt bbl...
07:02 offby1 sent
07:05 shar joined perl6
07:10 mugwump_ joined perl6
07:12 penk joined perl6
07:29 dduncan Is anyone aware of problems with the perl6-language list?  I sent a message to it over 5 hours ago and it hasn't propagated yet, where it usually propagates in a few minutes ... nntp.perl.org doesn't have it yet either
07:29 dduncan also, the newest messages either I or nntp.perl.org have are 15 hours old
07:36 jrockway power outage at the data center again?
07:41 bsb left perl6
07:43 iblechbot joined perl6
07:50 fayland joined perl6
07:57 weirdo dduncan, show the email address, i'll check if mx is available
08:07 dduncan weirdo, the list address is perl6-language@perl.org , and my sender address is [email@hidden.address]
08:08 weirdo % telnet  mx.develooper.com. 25
08:08 weirdo Trying 63.251.223.176...
08:08 weirdo mx is dead
08:09 dduncan since my message wasn't returned to me yet, I assume that it will get through if the server is fixed, then
08:11 drrho joined perl6
08:11 RHainsworth joined perl6
08:20 marmic joined perl6
08:52 anatolyv weirdo: you can't do "$val = if 1; 1; else 2;", but you can do "$val = do if 1; 1; else 2; "
08:53 * offby1 would probably have tried “$val = (1 ?? 1 !! 2)” or something like it
08:53 anatolyv weirdo: most things are expressions already, but a few are statements, but turnable into expressions with 'do'.
08:53 weirdo i see. thanks!
08:53 anatolyv offby1: sure, i'm not suggesting to use that as real code :)
08:54 * offby1 still feels that anyone who understands perl6 learned it through osmosis or something
08:55 offby1 must read synopses :-|
08:56 anatolyv weird: you asked about operator overloading. a concrete trivial example would be: sub infix:<+> ($x, $y) { $x*$y }
08:56 anatolyv weirdo: now 3+5 is 15 etc.
08:56 offby1 don't try that at home!
08:57 anatolyv better, if you do 'my sub...', overloading only takes effect in current block of {}.
08:58 anatolyv offby1: osmosis doesn't work, read those synopses! :)
08:58 offby1 that site that had the synopses with test cases mixed in sounds great, but last time I tried it it didn't work :-|
09:01 offby1 ah, better now.  Still a bit slow, but at least the page loaded.  (http://perlcabal.org/syn/S04.html if anyone cares)
09:02 lambdabot Title: S04
09:03 offby1 silly bot
09:13 weirdo anatolyv, can operators be overloaded for $@% individually?
09:15 weirdo i'd really love to have [] and []= for strings
09:15 anatolyv weirdo: not sure how you mean.
09:15 anatolyv weirdo: [] for strings is easy to have.
09:15 weirdo or << for arrays
09:15 anatolyv weirdo: same.
09:16 weirdo that's great! :-)
09:16 anatolyv weirdo: and already here with <==
09:16 anatolyv weirdo: the feed operator, more visual than << :)
09:17 anatolyv weirdo: to have [] for strings, simply define &postcircumfix:<[]> specifalised for the first argument being a Str.
09:18 anatolyv weirdo: (you can have many definitions of operators lying around, each working on its own class/es of arguments)
09:18 weirdo thanks! :-)
09:19 anatolyv weirdo: i think the reason it's not working by default is that in "string"[4..6], it's not clear what the numbers refer to: characters, bytes, graphemes. Perl6 strings are very very Unicode-friendly and can work on any of those levels.
09:21 rintaro joined perl6
09:21 weirdo i think i'd implement it in a way to honor unicode and fallback if 'use bytes;' is given
09:22 weirdo i've got an idea
09:22 weirdo {} could use bytes exclusively
09:23 anatolyv {} looks more like hash access to people. or a code block.
09:25 anatolyv but perl6 also has adverbs - colonised options you can pass to any operator/function. for example, we could have "string"[2..5]:c and "string"[2..5]:b
09:25 anatolyv with one of them being the default or something
09:29 H0LE left perl6
09:29 weirdo that looks really interesting. when there's a release, i might not use ruby anymore
09:30 weirdo there were some things i hated in ruby:
09:30 anatolyv there are regular releases :)
09:30 anatolyv they do not implement the full spec yet, and it's not perl6.0.0 yet
09:30 anatolyv but most functionality works, real-world IO is possible, real OOP is here etc.
09:31 weirdo even with duck typing there are exceptions thrown on unknown methods. that's bad, because i can't "foo"[42 .. -1].length and survive
09:31 weirdo i could def undefined_method in NilClass, but i'd actually have to add it to every class :-(
09:32 anatolyv I see what you mean.
09:32 weirdo also, there's no compile-time strict checking, as in perl's `use strict'
09:33 weirdo i can foo(val) without val ever being defined, the script will crash at runtime, when that specific code path is taken
09:33 weirdo for rare code paths, i could even submit a release with a variable name typo present :-(
09:34 anatolyv hmm, shades of perl4 :)
09:34 weirdo i thought ruby's (and lisp's) lambdas were unique, but in perl, closures work the same with anon (and named, too) subs
09:34 anatolyv since perl 5.0005 or so, I believe.
09:35 weirdo sounds unusual, but i've been writing perl for 5 years and i every so often learn such things
09:35 nikita2222 joined perl6
09:36 weirdo ruby's lambdas made me change some coding styles :-)
09:36 gaal I think closures existed before 5. Checking.
09:36 weirdo now i no longer have to pass things around, i just have to pass the anonymous sub :-)
09:36 gaal darn, I no longer have that perl4 handy.
09:37 weirdo parameter lists with opt-in pass-by-reference sound very neat, too!
09:37 weirdo i really hated these $$$$ :-)
09:37 anatolyv gaal: oh no!
09:38 weirdo i wonder. is there anything (apart from unit tests and contributed scripts) to do in pugs without knowing haskell?
09:38 weirdo if not, i might learn it as a result
09:39 anatolyv weirdo: well, when you say it like "contributed scripts" it doesn't sound all that important, but consider that a lot of the standard library modules fall into that category.
09:41 weirdo that's different :-)
09:41 weirdo i thought i could only write script examples in perl6
09:41 anatolyv so there's a lot of work to be done in perl6 and not haskell
09:41 ruoso joined perl6
09:42 weirdo can you direct me to a todo list?
09:43 gaal there's a TODO file
09:43 gaal one thing you might do is port your favorite p5 module
09:43 gaal as you go along, you may find pugs is missing a feature
09:43 gaal then you go write tests for that feature
09:44 gaal by then you'll have more familiarity with pugs itself, as well as with Perl 6
09:44 gaal sorry, TASKS
09:44 andara joined perl6
09:46 anatolyv hey andara
09:46 andara hi anatolyv]
09:47 anatolyv andara: are you working on ajaxifying runpugs, by any chance?
09:48 andara no I'm not. I don't have experience with ajax libraries. Also, I think runpugs should function without JS.
09:50 anatolyv andara: that could, I believe, be arranged while simultaneously providing ajax-like response to browsers with JS.
09:51 andara anatolyv: that would be great. At the moment I only use JS to make runpugs behave more like a terminal. Would you like to put in some asynchronous transfer functionality?
09:54 anatolyv andara: I'll see if I can do it. I don't have any real experience with ajax either, but if I find some time to learn and play with it... I was impressed with http://tryruby.hobix.com/, and think it'd be great if runpugs looked like that.
09:54 lambdabot Title: try ruby! (in your browser)
09:54 anatolyv andara: in terms of continuous screen presence.
09:57 andara anatolyv: yes, I agree, it looks quite cool. And not having screen flicker would definitely be a good thing. I mailed why to ask if I could use the libraries but I got no reply. They don't have any copyright/licensing info. The core is prototype.js though.
09:59 anatolyv andara: I mailed him also and likewise got no reply :)
10:01 andara anatolyv: shame. It would be a waste to have to rebuild the functionality from scratch. BTW, did you try the runpugs devel? I 'd like to release it to replace the current version if there are no obvious bugs.
10:03 anatolyv andara: no, I didn't know there was a development version noticeably different from stable. Will try!
10:06 andara anatolyv: it's at http://feather.perl6.nl:8080/cgi-bin/runpugs2
10:06 andara It has command history and some JS to make it more like a terminal.
10:06 andara There is also a non-interactive version where you can type in a full script: http://feather.perl6.nl:8080/cgi-bin/runpugs2?ia=0
10:06 lambdabot Title: Run Perl 6 Now -- in your browser!
10:06 lambdabot Title: Run Perl 6 Now -- in your browser!, http://tinyurl.com/ymunfl
10:08 anatolyv andara: great, thanks.
10:09 andara anatolyv: my pleasure :-)
10:10 dduncan left perl6
10:10 chris2 joined perl6
10:20 nikita2222 left perl6
10:34 iblechbot joined perl6
10:40 yhsuan left perl6
10:48 buetow joined perl6
11:14 xinming_ joined perl6
11:19 xor_ joined perl6
11:26 nipotan is now known as nipotaway
11:37 xinming_ is now known as xinming
11:38 ruoso joined perl6
11:43 capixaba joined perl6
12:04 GabrielVieira2 joined perl6
12:04 TimToady joined perl6
12:53 ruz joined perl6
13:40 chris2_ joined perl6
13:47 chris2_ is now known as chris2
13:53 gnuvince joined perl6
14:13 GabrielVieira2 is now known as GabrielVieira
14:27 Limbic_Region joined perl6
14:55 Bit-Man left perl6
14:56 GabrielVieira2 joined perl6
15:04 kisu joined perl6
15:15 buetow joined perl6
15:15 anatolyv so... i can say $obj.method($arg). can i say $obj.method $arg? Or does it _have_ to be $obj.methid: $arg?
15:20 bonesss joined perl6
15:22 capixaba joined perl6
15:45 xinming anatolyv: $obj.method: $arg isn't right either.
15:45 xinming method $obj: $arg
15:45 xinming method call must have parenthesis
15:45 andara left perl6
15:49 araujo joined perl6
15:49 penk joined perl6
15:51 AzureBOT joined perl6
15:53 weirdo when: my %foo; $foo{bar}{baz} or 1;
15:53 weirdo $foo{bar} -> undef; is created implicitly
15:54 weirdo why so? is there any point in Perl doing so?
15:54 weirdo makes checking for existence of variable-length hashes a bit hard
15:54 weirdo s/ of / of items in /
15:54 fglock_ joined perl6
15:55 xinming weirdo: please ask in #perl
15:55 xinming weirdo: here is for perl 6 developement only.
15:55 weirdo ok. sorry :-)
15:56 Gothmog_ weirdo: That behaviour is called autovivification. If you dereference an undef value, a var of the needed type is automagically created; if you want to check for existence, use exists(). perldoc -f exists
15:57 weirdo Gothmog_, it behaves the same. try: % perl -MData::Dumper -le 'my %foo; exists($foo{bar}{baz}); print Dumper %foo'
15:58 xor_ joined perl6
15:59 weirdo oh. i should check for every item first. sorry for the offtopic noise.
16:23 anatolyv xinming: no, that's wrong. See S03, "Invocant marker".
16:23 anatolyv xinming: $obj.method: $arg is fine.
16:25 anatolyv but i wonder if $obj.method $arg is.
16:28 xor_ joined perl6
16:30 anatolyv weirdo: to please you, Perl6 reduces autovivification to a small subset of cases compared to perl5 :)
16:30 anatolyv weirdo: see end section of http://dev.perl.org/perl6/doc/design/syn/S09.html
16:30 lambdabot Title: Synopsis 9: Data Structures - perl6:, http://tinyurl.com/y9yha2
16:30 kanru joined perl6
16:33 xinming anatolyv: hmm, sorry, I think my mind is out-dated. >_<
16:35 anatolyv :) no worries.
16:35 * anatolyv is trying to understand what "list operators" are, from the parser's point of view.
16:36 anatolyv S0{2,3} are not terribly clear on this.
16:40 markstos joined perl6
16:41 GabrielVieira2 is now known as GabrielVieira
16:41 xor_ joined perl6
16:54 diakopter joined perl6
17:00 diakopter left perl6
17:14 neonoen joined perl6
17:15 fglock_ anatolyv: a list operator is an identifier before a list, like ( add 1, 2, 3, 4 )
17:15 Juerd It is an operator that operates on a list.
17:15 Juerd [+] is not an identifier, but it is a list operator.
17:23 anatolyv fglock_, Juerd: the parser cannot know what it operates on what it must decide that it is a list operator.
17:24 anatolyv *when it must decide
17:26 anatolyv "a list", anyway, doesn't exist as a syntactic category. It's merely a term that happens to be an application of &infix:<,> .
17:28 justatheory joined perl6
17:28 anatolyv I'm trying to understand whether, from a parser's point of view, it is enough to say "a listop is either the comma or a prefix op with the same precedence as the comma", or there is more to it.
17:31 gnuvince ?eval [=>] ("hello", "world", "bonjour", "monde")
17:31 evalbot_r14842 ("hello" => ("world" => ("bonjour" => "monde")))
17:33 anatolyv ?eval hello => 'world'
17:33 evalbot_r14842 ("hello" => "world")
17:33 anatolyv ?eval [=>] 'hello', 'world'
17:33 evalbot_r14842 ("hello" => "world")
17:34 anatolyv ?eval [=>] hello, 'world'
17:34 evalbot_r14842 Error: No compatible subroutine found: "&hello"
17:36 fglock_ anatolyv: a listop can be declared with 'is assoc list'; unknown ops are parsed as 'provisional call', which makes it look like listop
17:37 ashleyb joined perl6
17:37 ludan joined perl6
17:40 Juerd anatolyv: Lists are created because of the list context introduced by the list operator.
17:41 Juerd anatolyv: In other words: the parser has to know which operators are list operators, because it cannot see this in the syntax.
17:41 anatolyv fglock: I think S?? use "list operator" in two different meanings. One is "something which is followed by an argument list (parsed in list context), and has the precedence of all listops". The other is "something with the predecence of all listops".
17:42 anatolyv for example: a bareword followed by whitespace is a listop in the first sense. It *must* have arguments after it.
17:42 anatolyv on the other hand, ... is called a listop, but it's really just about the precedence. It doesn't have to have an argument, and is a &term: then.
17:43 anatolyv listops in the first sense must be followed by whitespace, but ... doesn't have to be.
17:43 kanru joined perl6
17:43 anatolyv (nor does comma, which is an infix operator with list precedence)
17:44 anatolyv Juerd: lists are created because of the comma. It's an infix list-creating operator.
17:44 fglock_ anatolyv: sorry, I confused 'is assoc list' - it means a different thing
17:45 fglock_ anatolyv: the comma-op 'returns' a list
17:45 Juerd anatolyv: I don't believe that. I think that that is only possibly if we have a list data type, which we don't.
17:45 fglock_ a 'list operator' gets a list as an argument
17:46 Juerd Or I missed something again.
17:46 anatolyv fglock: that's what I'm saying. There is no such thing as a list to the parser. There is a listop though.
17:46 Juerd s/possibly/possible/
17:46 anatolyv Juerd: we have List and Seq, two of them.
17:46 Juerd Damn
17:46 Juerd The universe collapses.
17:46 anatolyv Juerd: comma in fact creates a Seq of its two arguments, I do believe.
17:48 anatolyv Juerd: it collapses in a good way, making everything simpler. It's a good thing that the parser, and in a way even the compiler, don't have to know what "comma" is.
17:50 anatolyv in the sense of not needing any special treatment for it.
17:50 fglock_ anatolyv: 'comma' can have many arguments - 1,2,3 is parsed as infix:<,>(1,2,3)
17:51 Juerd anatolyv: Simpler? It only adds needless complexity, like the possibility for having lists in non-list context.
17:52 anatolyv fglock_: an infix operator always has two arguments. In fact the way comma works depends on how its associativity is specified, which I think is underspecced, or at least I couldn't find it.
17:52 anatolyv fglock_: if comma is right-associative, 1,2,3 is infix:<,>(1, infix:<,>(2,3))
17:52 Juerd anatolyv: And it makes flattening a whole lot more complex, because you can no longer say that lists always flatten. After all, if you can have something in item context, there's no implied requirement for flattening it anymore.
17:53 anatolyv fglock_: if comma is list-associative, 1,2,3 is something like LIST(infix:<,>, 1,2,3) or whatever AST uses to represent list associativity.
17:53 fglock_ you use 'is assoc list' to specify this particular behaviour
17:53 Juerd So then you have to define which things flatten, and which don't.
17:53 Juerd And a definition is always harder to learn than an implied consequence.
17:54 anatolyv Juerd: I think a List will always auto-promote to an Array in scalar context, and will therefore flatten itself.
17:55 Juerd Arrays don't always flatten.
17:55 Juerd An array called @foo does flatten, an array called $foo does not.
17:56 Juerd We did away with references, so we can no longer call $foo a "reference to an array", and explain that it's not an array and *thus* won't flatten.
17:56 anatolyv Juerd: I'm not sure I understand the distinction. An array callde $foo will usually be a Scalar holding an Array inside it.
17:56 Juerd No, that's no longer true.
17:56 Juerd First, there is no Scalar.
17:56 anatolyv Juerd: it's a very recent understanding :)
17:56 Juerd A string is an object, an array is an object.
17:57 Juerd An object can be named $foo.
17:57 Juerd Or @foo, if the object likes that.
17:57 anatolyv Juerd: there is a Scalar, it's just not the perl5 scalar at all.
17:57 Juerd There's no longer the distinction between "pure arrays" (perl 5 @foo) and "referenced arrays" (perl 5 $foo, perl 5 [])
17:57 Juerd They're just Arrays
17:58 Juerd Perhaps there is Scalar.
17:58 Juerd And because references and "normal values" are no longer different, again we no longer have the implied consequence for assignment. Each data type will have to define whether it will copy its value. And that again is harder to learn than what we had in Perl 5.
17:59 anatolyv Juerd: no. I think you're not up to the distinction between value types and container types.
17:59 anatolyv Juerd: let me explain.
18:00 anatolyv Juerd: you're right there everything's an object. A string is an object, and an array is an object.
18:00 Juerd There are a lot of things in Perl 6 that I absolutely love. But the new variable/value/type system isn't one of them.
18:00 anatolyv Juerd: but you understand it incorrectly.
18:00 Juerd I hope so
18:00 Juerd Teach me :)
18:01 anatolyv Juerd: when you write, for example, my $foo = "string", you do *not* end up with $foo being a Str object. This is severely underexplained in the synposes, unfortunately, though it's mentioned.
18:02 Juerd No, $foo is a container containing the value "string" which is a Str
18:02 anatolyv what you end up with is $foo being a Scalar container object which contains a Str object inside itself. A Scalar can contain anything (any object of any class).
18:02 anatolyv "a contaner" is simply an object of a class that knows how to contain.
18:02 Juerd Right
18:03 Juerd But if you assign an array to $foo,
18:03 anatolyv typical such classes are: Scalar, Hash, Array.
18:03 Juerd what happens then?
18:03 anatolyv very simple: the Scalar $foo will hold an Array inside it. It's _almost_ identical, for all intents and purposes, to the situation in which you assign an array to @foo and end up an Array object.
18:04 anatolyv the reason it's almost identical is wheneve you write a variable name, it's really understood by the compiler to be a call to ITEM on the object of that name.
18:04 Juerd So, $foo = @bar means that $foo is a Scalar containing an Array, while @foo = @bar means that @foo is an Array?
18:05 anatolyv a Scalar's ITEM method reveals the object hidden inside the scalar and returns it, while an Array's ITEM method simple returns the same Array.
18:05 anatolyv Juerd: exactly.
18:05 anatolyv and so, after $foo = @bar, and after @foo = @bar, the results of $foo[1] and @foo[1] will be identical.
18:05 anatolyv because [1] is acting on $foo.ITEM and @foo.ITEM, really.
18:05 Grrrr joined perl6
18:05 Juerd But... $quux = $scalar_containing_string;  will copy the string value, while $quux = $scalar_containing_array will not copy the array...
18:05 anatolyv and both are Arrays.
18:06 anatolyv why wouldn't it copy the array? it's just an object, an Array, like a string is an object, a Str.
18:07 anatolyv the '$' in $foo is more or less a shortcut for 'is Scalar' (as well as part of the name).
18:07 Juerd What is it copying then?
18:07 Juerd The object, but not its contents?
18:07 anatolyv that is, you can say 'my $foo is Array', and you'll get a real Array with the name $foo, which is a bit perverse, but possible.
18:08 anatolyv but simple my $foo =  really means my $foo is Scalar = ...
18:08 anatolyv Juerd: I guess it asks the Array to clone its value, like it would ask a Str to clone its value?
18:09 Juerd I can also only guess.
18:10 anatolyv Juerd: after all, if you have my Moose $foo and my Moose $bar, and you later write $bar = $foo, you want the copy to be "by reference" and not create a new object.
18:11 anatolyv Juerd: which is what will happen, as Scalar $bar will hold the same Moose as Scalar $foo did.
18:15 Juerd anatolyv: I don't know if I will want that, or if I can reasonably expect that.
18:15 Juerd This is the area that I'm still wondering about, and will probably only understand when I see how I can tell Perl to treat my object a certain way.
18:16 Juerd It's like the postfix .[], which I'd love to override, but don't know how to, simply because I've never seen how.
18:16 Juerd Is postcircumfix:<[ ]> a method, a multi sub, who knows...
18:17 anatolyv a multi sub defined for an Array being the first argument, I think.
18:19 Juerd So for your own object you'd have to export one.
18:19 Juerd I must say that Ruby's "def []" is a bit simpler :)
18:20 anatolyv but i wonder if you have a method &postcircumfix:<[ ]> in your class, taking $self: and another argument, whether that'll work too.
18:20 anatolyv i can see how it can be made that it would, but i'm not up to date on MMD.
18:21 anatolyv you shouldn't have to write a multi sub for your class as the first argument when you can simply write a method instead. the compiler has all the information. the parser parses [] correctly because there's a proto multi sub.
18:33 Juerd Methods can be exported as multi subs, so yes, that can work.
18:33 Juerd But I wonder if that'll work by default or not
18:33 Juerd Or if you have to indicate this
18:37 drbean joined perl6
18:44 kanru joined perl6
18:46 elmex joined perl6
19:01 lazer left perl6
19:16 anatolyv Juerd: because the default [] is intentionally a multi sub and not a sub, the compiler'll push the resolution of the call to runtime dispatch, and that'll find your method (unless it's "my" or something).
19:17 anatolyv is perl6-language still borked?
19:17 Juerd Ah
19:17 Juerd I didn't know it was borked
19:18 anatolyv dduncan said here last night his email didn't come through... and their mx wasn't answering.
19:18 anatolyv all of perl.org's, I guess.
19:18 anatolyv I don't see any new messages on p5p either.
19:18 Juerd Hm, indeed it's kaputt
19:19 Juerd There are a lot of troubles with perl.org :(
19:19 Juerd DNS breakage, now MX breakage
19:19 anatolyv oh. I didn't know that.
19:19 Juerd Both protocols feature backup servers, but apparently that's not used.
19:19 Juerd Oh, it's used for DNS now
19:20 anatolyv guess it takes a failure of foo to set up foo right :)
19:20 Juerd Perhaps
19:24 gaal moosity
19:32 anatolyv indeed.
19:34 drbean_ joined perl6
19:52 cjeris joined perl6
19:58 cjeris left perl6
19:59 drbean joined perl6
20:30 cjeris joined perl6
20:30 TimToady anatolyv: $obj.method $arg is considered a syntax error of the two-terms-in-a-row variety
20:31 TimToady when the parsers sees "$obj.method +" it has to know whether to treat the + as a unary or an infix.
20:31 TimToady under current rules, this + is always infix
20:32 TimToady but the + in "$obj.method: +" is unambiguously a unary
20:32 anatolyv oh, I see.
20:32 drbean_ joined perl6
20:33 TimToady unlike in Perl 5, which occasionally does lookahead to determine term vs operator
20:33 TimToady Perl 6 never does so.
20:33 anatolyv TimToady: is it also true that list operators always have an argument, for the same reason?
20:33 TimToady any list operator may take 0 arguments.
20:33 anatolyv TimToady: say; is legal?
20:33 TimToady the space is only required if there is at least 1 arg
20:34 TimToady yes, that's legal.
20:34 TimToady this is also related to why "if" never starts a normal expression.
20:35 TimToady otherwise "foo if $bar" wouldn't
20:35 TimToady parse
20:35 anatolyv TimToady: so if there's a list operator, then whitespace, how is it different from the situation when there's $obj.method then whitespace? the parser also wouldn't know if what comes is a term (an argument for the list operator) or an infix.
20:35 TimToady so as with :, we require "do if" to distinguish
20:36 TimToady list operators default to looking for arguments, methods don't, because they already have one arg, which is often enough.
20:36 TimToady $obj.attr + 3 wants to treat $obj.attr as a variable, not a listop
20:37 anatolyv but isn't "looking for arguments" where arguments aren't guaranteed to be there a kind of lookahead?
20:37 TimToady well, sure, whenever I make an absolute statement it's probably wrong.   :)
20:38 anatolyv there're some words in S03 about how a function predeclared with 0 arity is not considered a list operator, and I thought it was exactly for that reason - to force list operators to have arguments, so there's no lookahead.
20:38 TimToady but in a sense backtracking to a null token after seeing ; or ) doesn't count.
20:38 TimToady since no token was traversed.
20:38 anatolyv hmm.
20:39 TimToady again, it comes down to how you treat "foo +"
20:39 TimToady that's the ambiguous case.  with "foo;" it doesn't matter.
20:41 anatolyv so basically, after a list operator+whitespace is a place where just about anything can come - both term-starting categories and infix, but perhaps infix is further down the list and therefore won't be matched if a prefix or a term of the same name are matched first.
20:43 TimToady that can be made to work, but perhaps there are failure modes that should simply be disallowed to avoid user confusion.
20:44 TimToady the requirement for space after a listop is somewhat arbitrary in that way.
20:44 TimToady it would be possible to allow "print$foo"
20:44 markstos joined perl6
20:44 anatolyv TimToady: what _is_ a list operator, to a parser? I mean, it's a little confusing. It's not a bona fide category like &prefix: or &term:. Comma is a list operator and an infix. Other listops look like prefixes, but now that you clarify that could always have 0 arguments, I guess they're more like... no other category :) instead.
20:46 anatolyv is a list operator "comma + any predeclared sub name with whitespace after it + any provisional bareword subname with whitespace after it"?
20:46 TimToady grammatically, a list operator is functioning like a left paren without a corresponding right paren, but using precedence to terminate rather than a right paren.
20:47 TimToady the listop precedence is special in being different looking left than looking right.
20:47 anatolyv Well, you could say _that_ about any prefix operator.
20:48 TimToady yes, all prefixes are very tight looking leftward, but listops are rather loose looking rightward.
20:48 anatolyv But prefixes, in general, unlike listops, do have to have an argument, right?
20:48 anatolyv or not so much right? :)
20:49 TimToady we have historically had prefix ops with optional args.
20:49 TimToady but like listops they have to default to looking for an argument in Perl 6.
20:49 TimToady $x = rand;
20:50 TimToady $x = rand 42
20:50 anatolyv isn't rand a listop here (sub name in listop form)?
20:50 anatolyv rather than a prefix op?
20:50 TimToady no, rand falls into the category of "named unary"
20:51 anatolyv damn :)
20:52 TimToady and sleep, and -e, etc.
20:52 anatolyv I understand how listops function grammatically. What I don't understand is - when the parser reads a token that turns out to be a listop, how does it fit into the system of grammatical categories of S02?
20:53 anatolyv I mean, that's what the categories are for - to tell the parser which categories to expect after this one. and as you just explained, after a listop we expect to see quite a lot.
20:54 anatolyv but is "a listop" something the parser needs to grok, or is it just "a prefixop with this precedence, or a comma infix op with this precedence"? that's what I don't understand.
20:54 TimToady listops are just prefix: category with listop precedence
20:54 TimToady (comma is just strange)
20:54 anatolyv great!
20:54 * anatolyv dances with joy.
20:55 TimToady we just lumped comma in with listop to save a precedence level, but syntactically it's more like an infix
20:56 anatolyv next question is - S03 says in one place that listops bind _looser_ than comma, but in the precedence list they're together with comma.
20:56 Aankhen`` joined perl6
20:56 anatolyv yeah, I don't see any problem with comma being a true &infix: of listop precedence! But to bind the list terms away from the listop, it has either to associate right, or to associate list, or something, not sure.
20:56 anatolyv if its and listops' precedence is the same.
20:57 anatolyv (it's never stated in the synposes that comma in fact 'is assoc list', Im unsure on that point)
20:58 TimToady it almost doesn't matter with comma since you just end up with a list in any event.
20:59 anatolyv I'm trying to avoid giving the comma special treatment in this parser I'm writing :)
21:00 anatolyv I understand how it doesn't matter if comma is assoc right or assoc list, for the eventual list, but I'm not sure how it prevents the listop from binding with less than the whole list.
21:01 anatolyv if it's not by precedence, then S03:267 should be corrected.
21:02 TimToady I'll have to think about it a bit.
21:02 anatolyv sure thing.
21:03 anatolyv is it alright to bother you with more spec-related questions now? :)
21:03 TimToady I'll have to wander off now.
21:03 TimToady but feel free to @tell me
21:03 TimToady or just put them here, since I always backlog.
21:04 TimToady biab &
21:04 Manni2000 joined perl6
21:04 anatolyv will do.
21:08 drbean joined perl6
21:11 ingy seen audreyt
21:11 jabbot ingy: audreyt was seen 14 hours 9 minutes 45 seconds ago
21:12 wolv joined perl6
21:23 larsen_ joined perl6
21:33 thepler joined perl6
21:36 thepler joined perl6
21:46 tech joined perl6
21:49 drbean_ joined perl6
22:12 wolv joined perl6
22:18 buetow joined perl6
22:24 sri_ joined perl6
22:26 sri_ joined perl6
22:27 sri_ joined perl6
22:29 BooK joined perl6
22:30 sri_ joined perl6
22:31 sri_ joined perl6
22:33 sri_ joined perl6
22:36 sri_ joined perl6
22:36 sri_ joined perl6
22:38 lisppaste3 joined perl6
22:39 sri_ joined perl6
22:50 sweinig|vermont is now known as sweinig
22:53 drbean joined perl6
23:12 drbean joined perl6
23:13 gnuvince joined perl6
23:18 nperez joined perl6
23:22 BooK_ joined perl6
23:30 justatheory joined perl6
23:56 tech left perl6

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

Perl 6 | Reference Documentation | Rakudo