Article View: comp.std.c
Article #4735Re: Two questions - Pointer equality and ...
From: Hallvard B Furuseth
Date: Thu, 01 Feb 1996 12:36
Date: Thu, 01 Feb 1996 12:36
31 lines
1750 bytes
1750 bytes
In article <4emonm$kqc@fnclub.fnal.gov> b91926@fnclub.fnal.gov (David Sachs) writes:
> I think it is rather unfortunate, that "const" came in so late.
>
> Logically the proper tye of a string literal should be const char*
> rather than char*, but there is just too much code written with
> the old usage, for such a change to ever be feasible.
Well, maybe. Consts that the programmer did not ask for can be a pain,
because the const qualifier cannot be propagated from a function
argument to the return value (or another function argument). So we get
into the habit of casting away consts, and will sometimes do it
incorrectly.
To fix this, C would need something with this semantics (using semi-C++
syntax):
const <C> /* Declare "C" as a "maybe-const" qualifier */
C char * /* Use C */
strchr (<C> char*); /* Set C from the function argument */
const <C> long strtol (<C> char *str, C char **ptr, int base);
/* Return the largest of two strings */
const <C1, C2> C1 C2 char *str_max (<C1> char *str1, <C2> char *str2);
I'm not sure whether to call that an argument for or against fixing the
matter...
--
Regards,
Hallvard
Technical Details
Message-ID:
<HBF.96Feb1133611@durin.uio.no>Path:
arc1-ca.pugleaf.net!nntp.uio.no!usenetReferences:
<4elq8a$j0b@taurus.fccc.edu> <TANMOY.96Jan30150808@qcd.lanl.gov> <9601310155.AA07417@dxmint.cern.ch> <4emonm$kqc@fnclub.fnal.gov>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!nntp.uio.no!usenet From: h.b.furuseth@usit.uio.no (Hallvard B Furuseth) Newsgroups: comp.std.c Subject: Re: Two questions - Pointer equality and ... Date: 1 Feb 1996 12:36:11 GMT Organization: University of Oslo, Norway Message-ID: <HBF.96Feb1133611@durin.uio.no> References: <4elq8a$j0b@taurus.fccc.edu> <TANMOY.96Jan30150808@qcd.lanl.gov> <9601310155.AA07417@dxmint.cern.ch> <4emonm$kqc@fnclub.fnal.gov> NNTP-Posting-Host: durin.uio.no In-reply-to: b91926@fnclub.fnal.gov's message of 30 Jan 1996 21:47:02 -0600