🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4778

Stdarg NULLs (was how pass argv to exec cde)

#4778
From: Peter Curran
Date: Tue, 20 Feb 1996 15:35
40 lines
2352 bytes
On 19 Feb 1996 16:28:01 GMT in article
<KANZE.96Feb19172802@slsvewt.lts.sel.alcatel.de>
    kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763) (James Kanze
US/ESC 60/3/141 #40763) wrote:

>In article <4fs44l$3p8@moody.mchh.siemens.de> Ronald Fischer
><ronald.fischer@uebemc.siemens.de> writes:

>|> The correct code is either
>|> {
>|>   char const path[]="c:\\dos\\edit.com";
>|>   execl(path,path,"zoo.asm",0);
>                               ^

>Wrong.  This is one of the rare cases where you have to cast the 0 (or
>NULL) to the correct type.

This leads to one of my long-imagined ideas for improving C . . . eliminating
this need to cast NULL (as well as numerous other benefits, such as improved
type checking of variable-length parameter lists, etc.).  The idea is to add a
new style of prototype:

int execl (const char *path, const char *arg...);

This implies a variable number of parameters, but (in this case) all of type
"const char *."  In my experience this is, after printf-type functions, the most
common situation in which variable numbers of parameters arise - all the
optional parameters are of the same type.  Unfortunately, the syntax is rather
subtle.

I have also imagined other enhancements to the prototype concept - fixed
parameters of a limited range of types, a variable but limited number of
parameters, variable number of parameters of a limited range of types, constant
parameters (to supply the trailing NULL for execl, for example) etc. - but these
have a limited cost/benefit ratio.  The existing one - unlimited variable
parameters of unlimited types - and the one I suggest here - unlimited variable
parameters of a single type - seem to me the most common and important cases.

--
Peter Curran                               pcurran@inforamp.net
Technical Details
Message-ID: <4gcota$h79@sam.inforamp.net>
Path: arc1-ca.pugleaf.net!inforamp.net!usenet
References: <4fbd0o$aj5@sunsic.si.univ-compiegne.fr> <4fs44l$3p8@moody.mchh.siemens.de> <KANZE.96Feb19172802@slsvewt.lts.sel.alcatel.de>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!inforamp.net!usenet
From: pcurran@inforamp.net (Peter Curran)
Newsgroups: comp.std.c
Subject: Stdarg NULLs (was how pass argv to exec cde)
Date: Tue, 20 Feb 1996 15:35:04 GMT
Organization: PSC Enterprises
Message-ID: <4gcota$h79@sam.inforamp.net>
References: <4fbd0o$aj5@sunsic.si.univ-compiegne.fr> <4fs44l$3p8@moody.mchh.siemens.de> <KANZE.96Feb19172802@slsvewt.lts.sel.alcatel.de>
Reply-To: pcurran@inforamp.net
NNTP-Posting-Host: ts45-08.tor.inforamp.net
X-Newsreader: Forte Free Agent 1.0.82