2009 -- the year of November. <november-wiki.org> <github.com/viklund/november> <irclog.perlgeek.de/november-wiki> <nopaste.snit.ch>
Set by moderator on 10 February 2009.
01:13 wayland76 joined 01:19 ihrd joined 05:18 ihrd joined 06:05 ihrd left 07:57 wayland76 joined 08:25 masak joined 10:37 wayland76 joined 10:52 ruoso joined 12:07 sri_kraih joined
masak I'm thinking Web.pm should have something like this: 12:29
www.ruby-doc.org/stdlib/libdoc/open...ml#M001413
zarah masak's link is also tinyurl.com/8z3a5k
masak is open() a multi in Perl 6?
(guessing it is, since most things in the core are)
moritz_ masak: you can be sure that every builtin is a multi (or nearly every)
masak thought so. 12:30
no need to check, then.
moritz_ but I really wouldn't want to call it open(), for security reasons
wayland76 I checked. It's multi
moritz_ it's a feature that you can't open() URL's in Perl 12:31
masak moritz_: if I have to import Web::URI or something, wouldn't it be OK?
moritz_ that has caused many troubles in PHP landscape
masak: no, because if you do your assumptions will no longer hold
masak moritz_: I see what you're getting at.
you'd have to validate your inputs in a new way. 12:32
wayland76 Have you seen the IO.uri function?
masak I have, but I've had time to forget about them :)
hm, maybe URIs are part of IO nowadays... 12:33
OK, getting concrete: imagine the functionality is there already; how would I fetch a web page with Perl 6? 12:34
moritz_ either URI.new($uri).fetch or my $response = get($url) or something 12:35
masak get is too general, too. 12:36
maybe .open on URI? 12:37
and then it works just like a filehandle.
wayland76 uri("www.example.com/").lines()
masak wayland76: nice!
wayland76: but I can live with typing URI.new there.
wayland76 There's no URI object, I think 12:38
moritz_ not in core
masak ah.
wayland76 You'd do HTTP.uri(...)
masak worksforme. 12:39
wayland76 Where HTTP does IO::Streamable
masak ah.
wayland76 (and HTTP is not in core)
masak :)
wayland76 Actually, HTTP does IO::Socket::TCP, probably
moritz_ roles - let's summon ruoso :-) 12:40
ruoso hi
zarah saluton ruoso
wayland76 Or, IO::Socket::TCP.new(RemoteHost => 'www.example.com', RemotePort => 80).lines();
masak I'd need all this pretty soon -- where should I start hacking? :) 12:41
wayland76: yuck.
wayland76: I don't mind it being simple.
wayland76 Well, much though you may not like it, I suspect that IO::Socket::TCP is the place to start hacking
ruoso masak, IO::Socket::INET is not that bad idea
masak ruoso: sure, I just thought the syntax in the last one was superfluous. 12:42
wayland76 (ok, listen to ruoso :) )
ruoso wayland76, IO::Socket::INET, actually... there's no reason to have a different role for TCP vs UDP
masak fetching a web page should be super-easy.
you can be as correct as you like under the hood.
ruoso masak, let the making it easy to be done by LWP ;)
wayland76 Well, HTTP is just an IO::Socket::TCP with a few default parameters
ruoso not really 12:43
wayland76 HTTP should be about two lines when IO::Socket::TCP is done :)
masak I just want something like URI.new("example.com").lines()
ruoso HTTP is a protocol
wayland76 Oh, yeah, good point :)
wayland76 slaps forehead :)
ruoso you can talk HTTP on top of whatever you like
wayland76 (own forehead, of course)
moritz_ and whatever we do, let's not call it LWP 12:44
that name seems like an historical accident
wayland76 Agreed :)
ruoso: Well, TCP appears in the draft spec :)
Would INET be streamable?
ruoso need to recall what streamable does 12:45
wayland76 auto-open, uri, and blocking, apparently 12:46
But maybe the roles need reorganisation :)
masak if you do reorganize, please remember my use case. :)
wayland76 masak: That uri("www.example.com/").lines() is already specced, and I'm keen to have it stay 12:47
ruoso is it still in S16, or did it went to the setting?
wayland76 No, S32/IO
masak wayland76: oh! good.
how much work would it be to make it work?
we have sockets now.
wayland76 But ruoso the one to convince :)
masak nah, just start using it. easier to get forgiveness than permission. :P 12:48
wayland76 I'd say not too much work.
masak what'd be the first step?
rakudo: say +uri("www.example.com/").lines()
p6eval rakudo 370dd7: OUTPUT«Could not find non-existent sub uri␤current instr.: '_block14' pc 60 (EVAL_16:40)␤»
masak &uri, it seems. 12:49
ruoso hmmm... it seems that uri is a method, not a function
wayland76 masak: read S32/IO.pod
masak reads
wayland76 uri is both a method and a function
In particular, I still think you'll need to do IO::Socket::TCP, and the roles it composes
ruoso right right
the difference between tcp and udp are not visible to the user... 12:50
wayland76 One thing we don't have is a way for things to add new protocols to the uri table :)
ruoso in terms of API, I mean
wayland76 No? Well, then, if we just change "TCP" to "INET" in the spec, will that still work? 12:51
masak method uri(Str $uri --> IO::Streamable);
that looks wrong to me.
no invocant colon.
moritz_ I'd expect uri() to return an URI object, not open stuff 12:52
remember that uri's can't be open in the general case, only URLs
masak aye. 12:53
wayland76 It only claims that file: http: and ftp: are possibilities at the moment.
ruoso I suggest to avoid trying to find the prettiest syntax now 12:54
wayland76 I think I'd be interested in seeing tcp://example.com:111/ working 12:55
ruoso tcp is not a application protocol
wayland76 I know, but my thought is that that would return an open IO::Socket to that port
ruoso I really think we should get the verbose code right 12:56
then we think how to make it short
i.e.: my $conn = IO::Socket::INET.new() is probably the best idea at this point
wayland76 So how do we specify that we want TCP vs. UDP? 12:57
Do we pass a "protocol" parameter, with a default of TCP? 12:58
masak ruoso: I agree about not being too hung up about nice syntax -- OTOH, we should not underestimate the convenience of same. many people will judge Perl 6 over exactly such details. 13:01
wayland76 Btw, I'm also thinking that uri() won't be able to interpret http urls unless "use HTTP" is done first 13:03
masak that's fine by me.
I guess method signatures will handle that seamlessly.
and also handle the case where a protocol is not recognized. 13:04
wayland76 I think we need another global variable :) 13:05
A hash that maps protocols to the classes that handle them
ruoso nah... 13:06
masak I never liked the first hash of protocols.
ruoso no need for globals...
wayland76 ie. 'http' => 'IO::Socket::HTTP'
ruoso multi uri($uri where /^/
multi uri($uri where /^http:/)
wayland76 Oh, can we do that?
I like it much better!
masak ruoso: that's what I was thinking as well. 13:07
ruoso but I insist... getting the syntax nice after having all the things sorted out is really easy... that is Perl 6 after all 13:08
so... let's focus on getting the things straight first...
masak fair enough.
wayland76 I think I'll focus on going to bed
masak I'd be happy with _some_ way to fetch a web page.
wayland76 it's after midnight now :)
masak making things happen is a good antidote to bikeshedding.
ruoso I'd suggest making IO::Socket::INET to work just like the p5 one 13:09
then make a HTTP module that uses it
wayland76 I wouldn't
The p6 one should auto-open 13:10
ruoso auto-open is syntax sugar
(if i see what you mean by auto-open)
wayland76 IO::Socket::INET should be opened as soon as it is created, unless NoOpen is passed in 13:11
ruoso why? 13:12
masak yes, why?
wayland76 Well, the reason I wrote the spec that way is that I figure that normally, when people create a socket, they want to open it :) 13:13
masak same could be said of files.
wayland76 Exactly, which is why IO::File also auto-opens :)
masak it does?
wayland76 Well, in the spec, anyway 13:14
masak what if I just want to check if a file exists?
wayland76 Then you use a FSNode
masak eeeew. 13:15
do not want.
wayland76 No? I thought keeping the inside and outside of a file separate was a good thing :)
But maybe not.
masak hm. maybe.
ruoso making them separate yes 13:16
making them different classes/roles? I doubt
wayland76 Anyway, it looks like the IO spec might need some discussion.
masak these are just my instinctive reactions, by the way. no rationales involved.
wayland76 Well, I'd be quite happy to wake up tomorrow and find a message or more about the IO spec in my p6l inbox 13:17
but my brain is shutting down now. Enen my typing is slowing........ 13:18
masak wayland76: sleep well.
wayland76 I'll try :)
ruoso good night wayland76
wayland76 'night all
ruoso but I'd say
roles doesn't represent state
and that seems to be a common mistake of roles usage
masak ruoso: do you mean to say that roles don't have attributes? 13:21
ruoso I mean that the fact of being composed with a role doesn't represent staet
i.e. IO::Readable
masak ah. 13:22
ruoso brb & 13:31
14:30 frioux_ joined 14:39 frioux_ joined 14:47 szabgab joined 14:56 wayland76 joined 14:59 mj41 joined 15:27 PerlJam joined 15:53 ihrd joined 15:59 ihrd left 19:16 szabgab joined 19:23 Tene_ joined 21:00 sri_kraih joined
wayland76 Btw, masak, I didn't say that :e "/path/to/file" still works for checking whether it exists 23:25