Skip Menu |
Report information
Id: 123949
Status: resolved
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: moritz <moritz.lenz+perl [at] gmail.com>
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



From: Moritz Lenz <moritz [...] faui2k3.org>
Date: Fri, 27 Feb 2015 17:23:36 +0100
To: rakudobug [...] perl.org
Subject: Inconsistent APIs for IO::Socket::Async and Proc::Async
Download (untitled) / with headers
text/plain 536b
Both IO::Socket::Async and Proc::Async have the options to get supplies for binary or string data, but there are two inconsitentcies: 1) Proc::Async has methods stdout(:$bin), IO::Socket::Async has chars_supply and bytes_supply. There should be some naming consistency here 2) Proc::Async has live supplies, and requires you to set them up before starting the process. IO::Socket::Async has on-demand supplies that you can get after the fact. In the interest of a smooth asynchronous experience, we should make them more consistent.
Subject: Re: [perl #123949] Inconsistent APIs for IO::Socket::Async and Proc::Async
To: perl6-compiler [...] perl.org
Date: Fri, 27 Feb 2015 23:57:27 +0100
From: Elizabeth Mattijsen <liz [...] dijkmat.nl>
Download (untitled) / with headers
text/plain 963b
Show quoted text
> On 27 Feb 2015, at 17:24, Moritz Lenz (via RT) <perl6-bugs-followup@perl.org> wrote: > > # New Ticket Created by Moritz Lenz > # Please include the string: [perl #123949] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=123949 > > > > Both IO::Socket::Async and Proc::Async have the options to get supplies > for binary or string data, but there are two inconsitentcies: > > 1) Proc::Async has methods stdout(:$bin), IO::Socket::Async has > chars_supply and bytes_supply. There should be some naming consistency here > > 2) Proc::Async has live supplies, and requires you to set them up before > starting the process. IO::Socket::Async has on-demand supplies that you > can get after the fact. > > In the interest of a smooth asynchronous experience, we should make them > more consistent.
I will take that into the newio branch, unless someone beats me to it in nom. Liz
To: Elizabeth Mattijsen <liz [...] dijkmat.nl>, perl6-compiler [...] perl.org
Subject: Re: [perl #123949] Inconsistent APIs for IO::Socket::Async and Proc::Async
From: Moritz Lenz <moritz [...] faui2k3.org>
Date: Wed, 04 Mar 2015 10:06:46 +0100
Download (untitled) / with headers
text/plain 1.4k
Hi, On 27.02.2015 23:57, Elizabeth Mattijsen wrote: Show quoted text
>> On 27 Feb 2015, at 17:24, Moritz Lenz (via RT) <perl6-bugs-followup@perl.org> wrote: >> >> # New Ticket Created by Moritz Lenz >> # Please include the string: [perl #123949] >> # in the subject line of all future correspondence about this issue. >> # <URL: https://rt.perl.org/Ticket/Display.html?id=123949 > >> >> >> Both IO::Socket::Async and Proc::Async have the options to get supplies >> for binary or string data, but there are two inconsitentcies: >> >> 1) Proc::Async has methods stdout(:$bin), IO::Socket::Async has >> chars_supply and bytes_supply. There should be some naming consistency here >> >> 2) Proc::Async has live supplies, and requires you to set them up before >> starting the process. IO::Socket::Async has on-demand supplies that you >> can get after the fact. >> >> In the interest of a smooth asynchronous experience, we should make them >> more consistent.
> > I will take that into the newio branch, unless someone beats me to it in nom.
Thanks. While I'm at it, there are two more inconsistencies between IO::Socket::Async and IO::Socket::INET: 1. IO::Socket::Async.connect() uses positional arguments for the host and port, while IO::Socket.:INET.new uses 2. ::Async uses separate .connect and .listen methods, ::INET uses a .new with a separate :listen argument to distinguish them. (I think I tend to prefer the separate methods approach). Cheers, Moritz
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 2.1k
Hi, I wrote these issues up in a gist: https://gist.github.com/jnthn/9d8b2e22882d7f7a871e They got some discussion on channel, and the decisions implemented. On Wed Mar 04 01:08:29 2015, moritz wrote: Show quoted text
> On 27.02.2015 23:57, Elizabeth Mattijsen wrote:
> >> On 27 Feb 2015, at 17:24, Moritz Lenz (via RT) <perl6-bugs- > >> followup@perl.org> wrote: > >> Both IO::Socket::Async and Proc::Async have the options to get > >> supplies > >> for binary or string data, but there are two inconsitentcies: > >> > >> 1) Proc::Async has methods stdout(:$bin), IO::Socket::Async has > >> chars_supply and bytes_supply. There should be some naming > >> consistency here > >>
Now IO::Socket::Async is consistent with IO::Handle: you have a .Supply method and can give it an optional :bin parameter. This is consistent with the :$bin parameter that stdout and stdin have on Proc::Async. Since there are two supplies you could want, then we can't just have .Supply on a Proc::Async. Updated S32-io/IO-Socket-Async.t to use the .Supply method. Show quoted text
> >> 2) Proc::Async has live supplies, and requires you to set them up > >> before > >> starting the process. IO::Socket::Async has on-demand supplies that > >> you > >> can get after the fact. > >>
When you are listening on a socket for incoming connections, you already have the socket, so there's no chance to take the supply earlier. With processes, obtaining the supplies has a secondary role of indicating what handles to bind when the process is spawned, which has to happen before we spawn it. So, the current design seems right. Show quoted text
> While I'm at it, there are two more inconsistencies between > IO::Socket::Async and IO::Socket::INET: > > 1. IO::Socket::Async.connect() uses positional arguments for the host > and port, while IO::Socket.:INET.new uses > > 2. ::Async uses separate .connect and .listen methods, ::INET uses a > .new with a separate :listen argument to distinguish them. (I think I > tend to prefer the separate methods approach). >
IO::Socket::INET gets to keep its new method, but it now also has connect and listen convenience methods, taking positional arguments, for consistency with IO::Socket::Async. Added tests in S32-io/IO-Socket-INET.t for new listen and connect methods. /jnthn


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org