Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Spock, did you see the looks on their faces?" "Yes, Captain, a sort of vacant contentment."


devel / comp.lang.c / Re: I think references should have been const by default

SubjectAuthor
o Re: I think references should have been const by defaultJames Kuyper

1
Re: I think references should have been const by default

<sl6eui$9q0$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18737&group=comp.lang.c#18737

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c
Subject: Re: I think references should have been const by default
Date: Mon, 25 Oct 2021 10:28:34 -0400
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <sl6eui$9q0$1@dont-email.me>
References: <skqtfl$17n5$1@gioia.aioe.org> <skr2r3$81j$1@dont-email.me>
<skrd0t$1p75$1@gioia.aioe.org> <skrh21$ksj$1@dont-email.me>
<skrqki$obd$1@gioia.aioe.org> <skrs1e$co2$1@dont-email.me>
<sktq8m$7ht$1@dont-email.me> <skuj0p$t60$1@dont-email.me>
<sl0nmu$bn3$1@dont-email.me> <sl0qcj$sub$1@dont-email.me>
<sl1e73$sl7$1@dont-email.me> <sl5pdi$4au$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 25 Oct 2021 14:28:34 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="06fec099c6d490d0f996f3ab9d03d86f";
logging-data="10048"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+SL42s/y+Jvv+IYYXDoEm0QTFdd6Y5PQk="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Cancel-Lock: sha1:jl8+CZqqqYvBN6GBJoEbSb3JWFE=
In-Reply-To: <sl5pdi$4au$1@gioia.aioe.org>
Content-Language: en-US
 by: James Kuyper - Mon, 25 Oct 2021 14:28 UTC

On 10/25/21 4:21 AM, RacingRabbit@watershipdown.co.uk wrote:
....
> Consts in C are pointless because it doesn't have references and its rather
> difficult to "accidentaly" dereference a pointer to update the value its
> pointing to.

Actually, it isn't. All it takes is unfamiliarity with the functions
you're using. I remember, in particular, I've seen messages from several
people expressing surprise that strtok() writes to the string that you
pass it as it's first argument. If the pointers they had tried to pass
to strtok() had been const char * rather than char*, they would have
been reminded of the problem. Of course, they might not have understood
the reminder, if they weren't familiar with functions whose declarations
use "const" appropriately. All of the standard library functions do so,
many other libraries don't.

However, that's only a part of the problem that "const" is intended to
help avoid. The other part is intentionally dereferencing a pointer to
update the value it's pointing act, due to being unaware of the fact
that what it's pointing at is something that shouldn't be written to. In
code which doesn't make proper use of "const", that's a fairly common
mistake, at least in my experience (which is admittedly limited, since
my own code does make proper use of "const").

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor