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:08
mjk joined
|
|||
dmq looks in | 00:10 | ||
buetow looks out :) | 00:11 | ||
00:11
gnuvince` joined
|
|||
eviltwin_b looks aside | 00:12 | ||
00:12
gnuvince joined
00:29
GabrielVieira2 is now known as GabrielVieira
00:30
nekokak joined
00:34
bonesss joined
00:44
bonesss joined
00:51
bsb joined
00:55
weirdo joined
|
|||
weirdo | hello | 00:55 | |
will operator overloading be possible with perl6? | |||
Juerd | Yes! | 00:57 | |
You can even invent your own operators, so you don't have to overload. (As overloading can be dangerous) | |||
weirdo | i'd personally love to make $string[4 .. 6] = 42; work | ||
i was hooked on ruby, but its scarce in modules | 00:58 | ||
its curses module is fubar :/ | |||
ruby had a certain influence on me - i discovered sub closures and anon subs in perl | 00:59 | ||
now i can't program without them :-) | |||
Juerd | Heh | 01:01 | |
Good for you :) | |||
gnuvince | ?eval my $s = "Hello"; substr($s, 0, 2) = 42; $s | ||
01:01
evalbot_r14838 is now known as evalbot_r14842
|
|||
evalbot_r14842 | \"42llo" | 01:01 | |
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. | ||
weirdo | including "," arg separator and parens | ||
gnuvince, ruby has it! :-) all kinds of | |||
gnuvince | in Ruby, String is an Enumerable IIRC | 01:03 | |
weirdo | str[1 .. 3] = "foo" # 2nd arg is index | ||
gnuvince | So it has #[], #[]= et al. | ||
weirdo | str[1 ... 3] = "foo" # 2nd arg is relative index | ||
will there be a switch statement? | |||
gnuvince | On steroids, yes. | 01:04 | |
It will be called given/when | |||
weirdo | oh. the one from Switch.pm! :-) | ||
gnuvince | perlcabal.org/syn/S04.html#Switch_statements | ||
lambdabot | Title: S04, tinyurl.com/y5beho | 01:05 | |
weirdo | will 'if' be a statement, so i could do '$val = if 1; 1; else 2; ? | ||
gnuvince | statement. | ||
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 :-) | ||
gnuvince | weirdo: get pugs :) | 01:06 | |
weirdo | does it cover all of perl6's specs? | ||
gnuvince | also, send me your email address in private message, I'll hook you up with a commit access | ||
Not all of it | |||
weirdo | is there a pugs cvs logs mailing list? | 01:11 | |
01:16
neonoen joined
01:23
kanru joined
01:37
jferrero joined
01:41
fayland joined
01:55
H0LE joined
01:56
bonesss joined
02:07
BooK joined,
nipotaway is now known as nipotan
02:09
bonesss joined
02:19
Psyche^ joined
02:20
yhsuan joined,
bonesss joined
02:27
Psyche^ is now known as Patterner
02:31
dmq joined
02:59
phpError joined
|
|||
ingy | seen audreyt | 02:59 | |
jabbot | ingy: audreyt was seen 3 days 14 hours 40 minutes 4 seconds ago | ||
03:06
bonesss joined
03:13
bonesss joined
03:28
phpError joined
03:33
ashleyb joined
04:23
vel joined
05:16
kanru joined
05:22
nekokak_ joined
05:44
phpError joined,
agentzh joined
|
|||
agentzh | seen audreyt | 05:45 | |
jabbot | agentzh: audreyt was seen 3 days 17 hours 25 minutes 30 seconds ago | ||
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. | ||
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
|
|||
weirdo | i wonder if operator overloading would be supported if $arr[0] wouldn't be changed to @arr[0] | 06:41 | |
06:42
rafl joined
|
|||
audreyt | how does those two relate? | 06:45 | |
lambdabot | audreyt: You have 4 new messages. '/msg lambdabot @messages' to read them. | ||
offby1 | audreyt: saw your talk at Amazon from last month. Enthralling | 06:54 | |
audreyt | video? or you were there? | 06:55 | |
offby1 | video | ||
bootlegged :-) | |||
audreyt | oooh. want! | 06:56 | |
upload it somewhere? I hear video uploading sites are plenty these days | |||
offby1 | I got the impression that it wasn't supposed to be broadcast, so ... | 06:57 | |
I've been unable to find documentation for (whatever the p6 equivalent is of) I/O layers. Is there any? | |||
audreyt | I certainly would like it to be broadcast... | ||
offby1: maybe ask @amazon.com source to see if I can make it available under CC license? | |||
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 | ||
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? :) | ||
offby1: k, thanks! | |||
I need to run soon | |||
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 | ||
offby1 | composing mail now | 07:01 | |
audreyt | danke | ||
bbl... | |||
offby1 | sent | 07:02 | |
07:05
shar joined
07:10
mugwump_ joined
07:12
penk joined
|
|||
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 | |
also, the newest messages either I or nntp.perl.org have are 15 hours old | |||
jrockway | power outage at the data center again? | 07:36 | |
07:41
bsb left
07:43
iblechbot joined
07:50
fayland joined
|
|||
weirdo | dduncan, show the email address, i'll check if mx is available | 07:57 | |
dduncan | weirdo, the list address is [email@hidden.address] , and my sender address is [email@hidden.address] | 08:07 | |
weirdo | % telnet mx.develooper.com. 25 | 08:08 | |
Trying 63.251.223.176... | |||
mx is dead | |||
dduncan | since my message wasn't returned to me yet, I assume that it will get through if the server is fixed, then | 08:09 | |
08:11
drrho joined,
RHainsworth joined
08:20
marmic joined
|
|||
anatolyv | weirdo: you can't do "$val = if 1; 1; else 2;", but you can do "$val = do if 1; 1; else 2; " | 08:52 | |
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'. | ||
weirdo | i see. thanks! | ||
anatolyv | offby1: sure, i'm not suggesting to use that as real code :) | ||
offby1 still feels that anyone who understands perl6 learned it through osmosis or something | 08:54 | ||
must read synopses :-| | 08:55 | ||
anatolyv | weird: you asked about operator overloading. a concrete trivial example would be: sub infix:<+> ($x, $y) { $x*$y } | 08:56 | |
weirdo: now 3+5 is 15 etc. | |||
offby1 | don't try that at home! | ||
anatolyv | better, if you do 'my sub...', overloading only takes effect in current block of {}. | 08:57 | |
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 :-| | ||
ah, better now. Still a bit slow, but at least the page loaded. (perlcabal.org/syn/S04.html if anyone cares) | 09:01 | ||
lambdabot | Title: S04 | 09:02 | |
offby1 | silly bot | 09:03 | |
weirdo | anatolyv, can operators be overloaded for $@% individually? | 09:13 | |
i'd really love to have [] and []= for strings | 09:15 | ||
anatolyv | weirdo: not sure how you mean. | ||
weirdo: [] for strings is easy to have. | |||
weirdo | or << for arrays | ||
anatolyv | weirdo: same. | ||
weirdo | that's great! :-) | 09:16 | |
anatolyv | weirdo: and already here with <== | ||
weirdo: the feed operator, more visual than << :) | |||
weirdo: to have [] for strings, simply define &postcircumfix:<[]> specifalised for the first argument being a Str. | 09:17 | ||
weirdo: (you can have many definitions of operators lying around, each working on its own class/es of arguments) | 09:18 | ||
weirdo | thanks! :-) | ||
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:19 | |
09:21
rintaro joined
|
|||
weirdo | i think i'd implement it in a way to honor unicode and fallback if 'use bytes;' is given | 09:21 | |
i've got an idea | 09:22 | ||
{} could use bytes exclusively | |||
anatolyv | {} looks more like hash access to people. or a code block. | 09:23 | |
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 | ||
with one of them being the default or something | |||
09:29
H0LE left
|
|||
weirdo | that looks really interesting. when there's a release, i might not use ruby anymore | 09:29 | |
there were some things i hated in ruby: | 09:30 | ||
anatolyv | there are regular releases :) | ||
they do not implement the full spec yet, and it's not perl6.0.0 yet | |||
but most functionality works, real-world IO is possible, real OOP is here etc. | |||
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 | |
i could def undefined_method in NilClass, but i'd actually have to add it to every class :-( | |||
anatolyv | I see what you mean. | 09:32 | |
weirdo | also, there's no compile-time strict checking, as in perl's `use strict' | ||
i can foo(val) without val ever being defined, the script will crash at runtime, when that specific code path is taken | 09:33 | ||
for rare code paths, i could even submit a release with a variable name typo present :-( | |||
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 | ||
anatolyv | since perl 5.0005 or so, I believe. | ||
weirdo | sounds unusual, but i've been writing perl for 5 years and i every so often learn such things | 09:35 | |
09:35
nikita2222 joined
|
|||
weirdo | ruby's lambdas made me change some coding styles :-) | 09:36 | |
gaal | I think closures existed before 5. Checking. | ||
weirdo | now i no longer have to pass things around, i just have to pass the anonymous sub :-) | ||
gaal | darn, I no longer have that perl4 handy. | ||
weirdo | parameter lists with opt-in pass-by-reference sound very neat, too! | 09:37 | |
i really hated these $$$$ :-) | |||
anatolyv | gaal: oh no! | ||
weirdo | i wonder. is there anything (apart from unit tests and contributed scripts) to do in pugs without knowing haskell? | 09:38 | |
if not, i might learn it as a result | |||
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:39 | |
weirdo | that's different :-) | 09:41 | |
i thought i could only write script examples in perl6 | |||
anatolyv | so there's a lot of work to be done in perl6 and not haskell | ||
09:41
ruoso joined
|
|||
weirdo | can you direct me to a todo list? | 09:42 | |
gaal | there's a TODO file | 09:43 | |
one thing you might do is port your favorite p5 module | |||
as you go along, you may find pugs is missing a feature | |||
then you go write tests for that feature | |||
by then you'll have more familiarity with pugs itself, as well as with Perl 6 | 09:44 | ||
sorry, TASKS | |||
09:44
andara joined
|
|||
anatolyv | hey andara | 09:46 | |
andara | hi anatolyv] | ||
anatolyv | andara: are you working on ajaxifying runpugs, by any chance? | 09:47 | |
andara | no I'm not. I don't have experience with ajax libraries. Also, I think runpugs should function without JS. | 09:48 | |
anatolyv | andara: that could, I believe, be arranged while simultaneously providing ajax-like response to browsers with JS. | 09:50 | |
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:51 | |
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 tryruby.hobix.com/, and think it'd be great if runpugs looked like that. | 09:54 | |
lambdabot | Title: try ruby! (in your browser) | ||
anatolyv | andara: in terms of continuous screen presence. | ||
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:57 | |
anatolyv | andara: I mailed him also and likewise got no reply :) | 09:59 | |
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:01 | |
anatolyv | andara: no, I didn't know there was a development version noticeably different from stable. Will try! | 10:03 | |
andara | anatolyv: it's at feather.perl6.nl:8080/cgi-bin/runpugs2 | 10:06 | |
It has command history and some JS to make it more like a terminal. | |||
There is also a non-interactive version where you can type in a full script: feather.perl6.nl:8080/cgi-bin/runpugs2?ia=0 | |||
lambdabot | Title: Run Perl 6 Now -- in your browser! | ||
Title: Run Perl 6 Now -- in your browser!, tinyurl.com/ymunfl | |||
anatolyv | andara: great, thanks. | 10:08 | |
andara | anatolyv: my pleasure :-) | 10:09 | |
10:10
dduncan left,
chris2 joined
10:20
nikita2222 left
10:34
iblechbot joined
10:40
yhsuan left
10:48
buetow joined
11:14
xinming_ joined
11:19
xor_ joined
11:26
nipotan is now known as nipotaway
11:37
xinming_ is now known as xinming
11:38
ruoso joined
11:43
capixaba joined
12:04
GabrielVieira2 joined,
TimToady joined
12:53
ruz joined
13:40
chris2_ joined
13:47
chris2_ is now known as chris2
13:53
gnuvince joined
14:13
GabrielVieira2 is now known as GabrielVieira
14:27
Limbic_Region joined
14:55
Bit-Man left
14:56
GabrielVieira2 joined
15:04
kisu joined
15:15
buetow joined
|
|||
anatolyv | so... i can say $obj.method($arg). can i say $obj.method $arg? Or does it _have_ to be $obj.methid: $arg? | 15:15 | |
15:20
bonesss joined
15:22
capixaba joined
|
|||
xinming | anatolyv: $obj.method: $arg isn't right either. | 15:45 | |
method $obj: $arg | |||
method call must have parenthesis | |||
15:45
andara left
15:49
araujo joined,
penk joined
15:51
AzureBOT joined
|
|||
weirdo | when: my %foo; $foo{bar}{baz} or 1; | 15:53 | |
$foo{bar} -> undef; is created implicitly | |||
why so? is there any point in Perl doing so? | 15:54 | ||
makes checking for existence of variable-length hashes a bit hard | |||
s/ of / of items in / | |||
15:54
fglock_ joined
|
|||
xinming | weirdo: please ask in #perl | 15:55 | |
weirdo: here is for perl 6 developement only. | |||
weirdo | ok. sorry :-) | ||
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:56 | |
weirdo | Gothmog_, it behaves the same. try: % perl -MData::Dumper -le 'my %foo; exists($foo{bar}{baz}); print Dumper %foo' | 15:57 | |
15:58
xor_ joined
|
|||
weirdo | oh. i should check for every item first. sorry for the offtopic noise. | 15:59 | |
anatolyv | xinming: no, that's wrong. See S03, "Invocant marker". | 16:23 | |
xinming: $obj.method: $arg is fine. | |||
but i wonder if $obj.method $arg is. | 16:25 | ||
16:28
xor_ joined
|
|||
anatolyv | weirdo: to please you, Perl6 reduces autovivification to a small subset of cases compared to perl5 :) | 16:30 | |
weirdo: see end section of dev.perl.org/perl6/doc/design/syn/S09.html | |||
lambdabot | Title: Synopsis 9: Data Structures - perl6:, tinyurl.com/y9yha2 | ||
16:30
kanru joined
|
|||
xinming | anatolyv: hmm, sorry, I think my mind is out-dated. >_< | 16:33 | |
anatolyv | :) no worries. | 16:35 | |
anatolyv is trying to understand what "list operators" are, from the parser's point of view. | |||
S0{2,3} are not terribly clear on this. | 16:36 | ||
16:40
markstos joined
16:41
GabrielVieira2 is now known as GabrielVieira,
xor_ joined
16:54
diakopter joined
17:00
diakopter left
17:14
neonoen joined
|
|||
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. | ||
[+] is not an identifier, but it is a list operator. | |||
anatolyv | fglock_, Juerd: the parser cannot know what it operates on what it must decide that it is a list operator. | 17:23 | |
*when it must decide | 17:24 | ||
"a list", anyway, doesn't exist as a syntactic category. It's merely a term that happens to be an application of &infix:<,> . | 17:26 | ||
17:28
justatheory joined
|
|||
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:28 | |
gnuvince | ?eval [=>] ("hello", "world", "bonjour", "monde") | 17:31 | |
evalbot_r14842 | ("hello" => ("world" => ("bonjour" => "monde"))) | ||
anatolyv | ?eval hello => 'world' | 17:33 | |
evalbot_r14842 | ("hello" => "world") | ||
anatolyv | ?eval [=>] 'hello', 'world' | ||
evalbot_r14842 | ("hello" => "world") | ||
anatolyv | ?eval [=>] hello, 'world' | 17:34 | |
evalbot_r14842 | Error: No compatible subroutine found: "&hello" | ||
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:36 | |
17:37
ashleyb joined,
ludan joined
|
|||
Juerd | anatolyv: Lists are created because of the list context introduced by the list operator. | 17:40 | |
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". | ||
for example: a bareword followed by whitespace is a listop in the first sense. It *must* have arguments after it. | 17:42 | ||
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. | |||
listops in the first sense must be followed by whitespace, but ... doesn't have to be. | 17:43 | ||
17:43
kanru joined
|
|||
anatolyv | (nor does comma, which is an infix operator with list precedence) | 17:43 | |
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 | ||
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. | ||
fglock_ | a 'list operator' gets a list as an argument | ||
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. | ||
Juerd | s/possibly/possible/ | ||
anatolyv | Juerd: we have List and Seq, two of them. | ||
Juerd | Damn | ||
The universe collapses. | |||
anatolyv | Juerd: comma in fact creates a Seq of its two arguments, I do believe. | ||
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:48 | ||
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) | ||
Juerd | anatolyv: Simpler? It only adds needless complexity, like the possibility for having lists in non-list context. | 17:51 | |
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 | |
fglock_: if comma is right-associative, 1,2,3 is infix:<,>(1, infix:<,>(2,3)) | |||
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. | ||
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 | ||
Juerd | So then you have to define which things flatten, and which don't. | ||
And a definition is always harder to learn than an implied consequence. | |||
anatolyv | Juerd: I think a List will always auto-promote to an Array in scalar context, and will therefore flatten itself. | 17:54 | |
Juerd | Arrays don't always flatten. | 17:55 | |
An array called @foo does flatten, an array called $foo does not. | |||
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. | ||
Juerd | No, that's no longer true. | ||
First, there is no Scalar. | |||
anatolyv | Juerd: it's a very recent understanding :) | ||
Juerd | A string is an object, an array is an object. | ||
An object can be named $foo. | 17:57 | ||
Or @foo, if the object likes that. | |||
anatolyv | Juerd: there is a Scalar, it's just not the perl5 scalar at all. | ||
Juerd | There's no longer the distinction between "pure arrays" (perl 5 @foo) and "referenced arrays" (perl 5 $foo, perl 5 []) | ||
They're just Arrays | |||
Perhaps there is Scalar. | 17:58 | ||
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. | |||
anatolyv | Juerd: no. I think you're not up to the distinction between value types and container types. | 17:59 | |
Juerd: let me explain. | |||
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. | ||
anatolyv | Juerd: but you understand it incorrectly. | ||
Juerd | I hope so | ||
Teach me :) | |||
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:01 | |
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). | ||
"a contaner" is simply an object of a class that knows how to contain. | |||
Juerd | Right | ||
But if you assign an array to $foo, | 18:03 | ||
anatolyv | typical such classes are: Scalar, Hash, Array. | ||
Juerd | what happens then? | ||
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. | ||
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? | ||
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 | |
Juerd: exactly. | |||
and so, after $foo = @bar, and after @foo = @bar, the results of $foo[1] and @foo[1] will be identical. | |||
because [1] is acting on $foo.ITEM and @foo.ITEM, really. | |||
18:05
Grrrr joined
|
|||
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. | ||
why wouldn't it copy the array? it's just an object, an Array, like a string is an object, a Str. | 18:06 | ||
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? | ||
The object, but not its contents? | |||
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. | ||
but simple my $foo = really means my $foo is Scalar = ... | 18:08 | ||
Juerd: I guess it asks the Array to clone its value, like it would ask a Str to clone its value? | |||
Juerd | I can also only guess. | 18:09 | |
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:10 | |
Juerd: which is what will happen, as Scalar $bar will hold the same Moose as Scalar $foo did. | 18:11 | ||
Juerd | anatolyv: I don't know if I will want that, or if I can reasonably expect that. | 18:15 | |
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. | |||
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 | ||
Is postcircumfix:<[ ]> a method, a multi sub, who knows... | |||
anatolyv | a multi sub defined for an Array being the first argument, I think. | 18:17 | |
Juerd | So for your own object you'd have to export one. | 18:19 | |
I must say that Ruby's "def []" is a bit simpler :) | |||
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 | |
i can see how it can be made that it would, but i'm not up to date on MMD. | |||
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:21 | ||
Juerd | Methods can be exported as multi subs, so yes, that can work. | 18:33 | |
But I wonder if that'll work by default or not | |||
Or if you have to indicate this | |||
18:37
drbean joined
18:44
kanru joined
18:46
elmex joined
19:01
lazer left
|
|||
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:16 | |
is perl6-language still borked? | 19:17 | ||
Juerd | Ah | ||
I didn't know it was borked | |||
anatolyv | dduncan said here last night his email didn't come through... and their mx wasn't answering. | 19:18 | |
all of perl.org's, I guess. | |||
I don't see any new messages on p5p either. | |||
Juerd | Hm, indeed it's kaputt | ||
There are a lot of troubles with perl.org :( | 19:19 | ||
DNS breakage, now MX breakage | |||
anatolyv | oh. I didn't know that. | ||
Juerd | Both protocols feature backup servers, but apparently that's not used. | ||
Oh, it's used for DNS now | |||
anatolyv | guess it takes a failure of foo to set up foo right :) | 19:20 | |
Juerd | Perhaps | ||
gaal | moosity | 19:24 | |
anatolyv | indeed. | 19:32 | |
19:34
drbean_ joined
19:52
cjeris joined
19:58
cjeris left
19:59
drbean joined
20:30
cjeris joined
|
|||
TimToady | anatolyv: $obj.method $arg is considered a syntax error of the two-terms-in-a-row variety | 20:30 | |
when the parsers sees "$obj.method +" it has to know whether to treat the + as a unary or an infix. | 20:31 | ||
under current rules, this + is always infix | |||
but the + in "$obj.method: +" is unambiguously a unary | 20:32 | ||
anatolyv | oh, I see. | ||
20:32
drbean_ joined
|
|||
TimToady | unlike in Perl 5, which occasionally does lookahead to determine term vs operator | 20:33 | |
Perl 6 never does so. | |||
anatolyv | TimToady: is it also true that list operators always have an argument, for the same reason? | ||
TimToady | any list operator may take 0 arguments. | ||
anatolyv | TimToady: say; is legal? | ||
TimToady | the space is only required if there is at least 1 arg | ||
yes, that's legal. | 20:34 | ||
this is also related to why "if" never starts a normal expression. | |||
otherwise "foo if $bar" wouldn't | 20:35 | ||
parse | |||
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. | ||
TimToady | so as with :, we require "do if" to distinguish | ||
list operators default to looking for arguments, methods don't, because they already have one arg, which is often enough. | 20:36 | ||
$obj.attr + 3 wants to treat $obj.attr as a variable, not a listop | |||
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. :) | ||
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. | ||
since no token was traversed. | |||
anatolyv | hmm. | ||
TimToady | again, it comes down to how you treat "foo +" | 20:39 | |
that's the ambiguous case. with "foo;" it doesn't matter. | |||
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:41 | |
TimToady | that can be made to work, but perhaps there are failure modes that should simply be disallowed to avoid user confusion. | 20:43 | |
the requirement for space after a listop is somewhat arbitrary in that way. | 20:44 | ||
it would be possible to allow "print$foo" | |||
20:44
markstos joined
|
|||
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:44 | |
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. | ||
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. | ||
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? | ||
or not so much right? :) | |||
TimToady | we have historically had prefix ops with optional args. | 20:49 | |
but like listops they have to default to looking for an argument in Perl 6. | |||
$x = rand; | |||
$x = rand 42 | 20:50 | ||
anatolyv | isn't rand a listop here (sub name in listop form)? | ||
rather than a prefix op? | |||
TimToady | no, rand falls into the category of "named unary" | ||
anatolyv | damn :) | 20:51 | |
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? | ||
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:53 | ||
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 | ||
(comma is just strange) | |||
anatolyv | great! | ||
anatolyv dances with joy. | |||
TimToady | we just lumped comma in with listop to save a precedence level, but syntactically it's more like an infix | 20:55 | |
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 | |
20:56
Aankhen`` joined
|
|||
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 | |
if its and listops' precedence is the same. | |||
(it's never stated in the synposes that comma in fact 'is assoc list', Im unsure on that point) | 20:57 | ||
TimToady | it almost doesn't matter with comma since you just end up with a list in any event. | 20:58 | |
anatolyv | I'm trying to avoid giving the comma special treatment in this parser I'm writing :) | 20:59 | |
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:00 | ||
if it's not by precedence, then S03:267 should be corrected. | 21:01 | ||
TimToady | I'll have to think about it a bit. | 21:02 | |
anatolyv | sure thing. | ||
is it alright to bother you with more spec-related questions now? :) | 21:03 | ||
TimToady | I'll have to wander off now. | ||
but feel free to @tell me | |||
or just put them here, since I always backlog. | |||
biab & | 21:04 | ||
21:04
Manni2000 joined
|
|||
anatolyv | will do. | 21:04 | |
21:08
drbean joined
|
|||
ingy | seen audreyt | 21:11 | |
jabbot | ingy: audreyt was seen 14 hours 9 minutes 45 seconds ago | ||
21:12
wolv joined
21:23
larsen_ joined
21:33
thepler joined
21:36
thepler joined
21:46
tech joined
21:49
drbean_ joined
22:12
wolv joined
22:18
buetow joined
22:24
sri_ joined
22:26
sri_ joined
22:27
sri_ joined
22:29
BooK joined
22:30
sri_ joined
22:31
sri_ joined
22:33
sri_ joined
22:36
sri_ joined
22:38
lisppaste3 joined
22:39
sri_ joined
22:50
sweinig|vermont is now known as sweinig
22:53
drbean joined
23:12
drbean joined
23:13
gnuvince joined
23:18
nperez joined
23:22
BooK_ joined
23:30
justatheory joined
23:56
tech left
|