Skip Menu |

This queue is for tickets about the IPC-Signal CPAN distribution.

Report information
The Basics
Id: 11464
Status: new
Priority: 0/
Queue: IPC-Signal

People
Owner: ROSCH [...] cpan.org
Requestors: ROSCH [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: make sig_name()/sig_num() accept both numbers and names
This is a request from zefram at fysh dot org: Date: Wed, 26 Jan 2005 22:38:38 +0000 To: roderick@argon.org Subject: IPC::Signal and polymorphism Message-ID: <20050126223838.GA9994@fysh.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.28i In writing signal-handling functions in Perl, it becomes annoying that there are two common forms in which signal identities are represented: the numbers and the names. Different Perl functions require different forms, and of course that's what IPC::Signal is there to help with. But I'd prefer to avoid propagating this annoyance through the signal-handling functions that I write. I'd like to make my functions polymorphic, accepting either a signal number or name, whichever is more convenient for the caller. In order to do this, it would be really helpful to have a function that accepts a signal number-or-name and returns a signal number, and a function that accepts a signal number-or-name and returns a signal name. These would, of course, be polymorphic versions of sig_num() and sig_name(). Therefore I propose that sig_num() and sig_name() in IPC::Signal should behave in that way, accepting either numbers or names. If sig_num() and sig_name() behaved like that, then a lot of signal handling code would instantly become polymorphic in the manner that I propose, without any effort on the part of its author. I think this would be a nice bit of DWIMery. What do you think? -zefram
Great. I had another, complementary, idea today after reading your email: imagine a dualvar (see Scalar::Util) which has a string value of a signal name and a numeric value of the corresponding signal number. Such an object would be handy to pass to a function that wants either a signal name or number and you can't remember which it wants. It would be handy in general handling of signal identities, shortcutting the translation process. It would be conceivable to turn sig_num() and sig_name() into the same function, returning these dualvars instead of (respectively) numbers and names. But there are compatibility dragons there, so I suggest instead that there be a third function, perhaps sig_id(), which accepts a signal name or number and returns a dualvar. -zefram