Subject: Re: Curious SYNOPSIS in signal(3)
To: None <current-users@netbsd.org>
From: Greg A. Woods <woods@weird.com>
List: current-users
Date: 06/25/2002 20:33:46
[ On Tuesday, June 25, 2002 at 16:59:33 (-0700), Greywolf wrote: ]
> Subject: Re: Curious SYNOPSIS in signal(3)
>
> On 25 Jun 2002, Eric Jacoboni wrote:
>
> # Also, the FreeBSD's typedef'd synopsys is somewhat clearer:
> #
> # /-----------------
> # | typedef void (*sig_t)(int);
> # |
> # | sig_t
> # | signal(int sig, sig_t func);
> # \-----------------
> #
> # it could be nice to add it in the synopsis as an alternative for the
> # basic syntax.
>
> How is typedef'ing it clearer than inlining it?
Indeed.
I usually find typedef'ed function pointers less clear -- there's
nothing but a naming convention in the last lines of the above quoted
declaration to suggest that a sig_t is indeed a pointer to a function,
whereas in the explicitly written variant is very clearly showing a
declaration for a function that returns a pointer to a function, and
which takes a pointer to a function as its second parameter.
(phew! it's almost easier to say "She sells C shells by the sea shore"!)
However they're sometimes easier to use -- especially in casts and/or
with prototypes.... Witness the NetBSD manpage synopsis. I know people
(_not_ me! :-) who'd complain that lisp is easier to read! ;-)
--
Greg A. Woods
+1 416 218-0098; <gwoods@acm.org>; <g.a.woods@ieee.org>; <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>