comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Flexible Strings (was Equality operator...)
Date: 1997/05/07
Date: 1997-05-07T00:00:00+00:00	[thread overview]
Message-ID: <dewar.863062901@merv> (raw)
In-Reply-To: 5kocg6$hln@bcrkh13.bnr.ca


<<But the C standard firmly says that ``The free function causes the space
pointed to by ptr to be deallocated, that is, made available for further
allocation'' (ISO 9899:1990 7.10.3.2 The free function). This pretty much
constitutes a requirement that the C implementation actually deallocate
when free is called, which carries more weight than a mere observation
about what all existing implementations do.>>


That's a misconception. The above statement is one of intent, but it
has no semantic force, because it would be impossible to specify the
conditions under which storage could be reused. For example if the
total heap size is 2N words, and we allocate two blocks of N and then
free them, then can we allocate a single 2N word block -- the C
standard is silent on this, and indeed has to be.

So the above paragraph is not "firmly" saying anything. An implementation
that ignores free is formally conformant. It would take the attitude that
the storage is indeed made available for further allocation, but
unfortunately none of your subsequent requests were able to be filled
using this storage.

Of course a C compiler that abused this too much would be useless and no one
would use it, just as an Ada compiler that ignored unchecked deallocation
would also be useless. Note that the Ada RM does indeed say:

17   For a standard storage pool, Free should actually reclaim the storage.

which has just as much force from a formal point of view as the statementin the C standard. In the Ada RM it is Implementation Advice, which is much more
honest. In the C standard it is also implementation advice, but it is less
obvious that this is the case, as we seel from Kaz's post.

It is a very common misconception for those without experience in what
semantic definition is about, and what as-if semantics are about, to want
to put statements like this into a language definition, but it is misleading
and confusing. However, there is usually enough vocal support for such
semantic nonsense that it creeps in from time to time in any language
standard (the Ada RM is not without its examples of this kind of thing!)

Actually I think the Implementation Advice sections in the RM are very
helpful, because, since they are non-normative, you can use rather informal
("you know what I mean") kind of language, and say things that you could
not say at all in normative text.





  reply	other threads:[~1997-05-07  0:00 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-04-30  0:00 Flexible Strings (was Equality operator...) W. Wesley Groleau (Wes)
1997-04-30  0:00 ` Matthew Heaney
1997-05-01  0:00   ` Robert Dewar
1997-05-02  0:00   ` Kevin Cline
1997-05-03  0:00     ` Jon S Anthony
1997-05-03  0:00     ` Robert Dewar
1997-05-04  0:00       ` Kevin Cline
1997-05-04  0:00         ` Robert Dewar
1997-05-06  0:00           ` Kaz Kylheku
1997-05-07  0:00             ` Robert Dewar [this message]
1997-05-07  0:00             ` Kevin Cline
1997-05-07  0:00               ` Robert A Duff
1997-05-07  0:00               ` Matthew Heaney
1997-05-07  0:00                 ` Jon S Anthony
1997-05-07  0:00               ` Robert Dewar
1997-05-07  0:00               ` Jon S Anthony
1997-05-07  0:00             ` Robert Dewar
1997-05-07  0:00             ` Robert A Duff
1997-05-07  0:00               ` Robert Dewar
1997-05-08  0:00               ` Robert I. Eachus
1997-05-09  0:00           ` Erik Magnuson
1997-05-10  0:00             ` John G. Volan
1997-05-10  0:00               ` Robert Dewar
1997-05-10  0:00                 ` Matthew Heaney
1997-05-11  0:00                   ` Robert Dewar
1997-05-12  0:00               ` Erik Magnuson
1997-05-10  0:00             ` Robert Dewar
1997-05-10  0:00               ` Matthew Heaney
     [not found] <199705010554.WAA24507@ni1.ni.net>
1997-05-01  0:00 ` W. Wesley Groleau (Wes)
1997-05-02  0:00   ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox