On 2021-04-18 11:09, Jeffrey R. Carter wrote:
On 4/18/21 10:46 AM, Gautier write-only address wrote:
Side note: did anyone already suggest a new keyword: unchecked_free
and a special statement:
unchecked_free Some_Pointer;
For every access variable P, there could exist the attribute procedure
P'Free;
I like the idea of attaching it to a variable rather than to type.
-------------
I remember the claim that originally making it a generic procedure with
an indigestible name was meant as barrier for lazy programmers.
Plus
some considerations regarding garbage collection lurked in the subconscious.
Well, P'Free can also be in another package... Of course, we are talking here only about the direct, actual deallocation.
If you want to precisely know where deallocation is used, use AdaControl (for any solution). If you want to be confident that there is no direct deallocation in a module, the generic wins.
It loses because you can have direct, immediate deallocation without the "with Ada.Unchecked_Deallocation" somewhere in the context clause.
pack.ads:
with Ada.Unchecked_Deallocation;
package Pack is
type IA is access Integer;
procedure Release is new Ada.Unchecked_Deallocation (Integer, IA);
end;
----
proc.adb:
with Pack;
procedure Proc is
use Pack;
P : IA;
begin
P := new Integer;
Release (P);
end;
In article <s5h0o5$1piu$1@gioia.aioe.org>,
"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:
On 2021-04-18 11:09, Jeffrey R. Carter wrote:
On 4/18/21 10:46 AM, Gautier write-only address wrote:
Side note: did anyone already suggest a new keyword: unchecked_free
and a special statement:
unchecked_free Some_Pointer;
For every access variable P, there could exist the attribute procedure
P'Free;
I like the idea of attaching it to a variable rather than to type.
why?
if it had to be made, i would say it could not be less than sth like: T'Unchecked_Free (P)
I remember the claim that originally making it a generic procedure with
an indigestible name was meant as barrier for lazy programmers.
not only that:
i agree J-P. Rosen (he didn't said exactly that),
it's fine to be able to search for the "Unchecked" keyword, to look at
parts of code with some known risk (afaik):
Ada.Unchecked_Deallocation, Ada.Unchecked_Conversion, Unchecked_Access.
Plus
some considerations regarding garbage collection lurked in the subconscious.
could you explain, please ? :-)
"Niklas Holsti" <niklas.holsti@tidorum.invalid> wrote in message news:ie8uagFqaf2U1@mid.individual.net...
On 2021-04-20 23:32, Jeffrey R. Carter wrote:
On 4/20/21 8:53 PM, Randy Brukardt wrote:
'Free makes more sense in a new language (an Ada follow-on).
Right. I don't think it would be a good idea to add it to Ada.
But I think a new language should not have pointers at all.
No more radical than not having arrays.
It seems to me that a language without arrays and pointers would be very difficult to use in an embedded, real-time, close-to-HW context. So we would lose the nice wide-spectrum nature of Ada.
It's important that a new language have a way to interface to existing hardware and software. So there has to be something that maps to C arrays
and pointers (and the equivalent for hardware). But that doesn't necessarily have to be something that is used outside of interfacing. An Ada example is Unchecked_Unions -- they exist for interfacing but shouldn't be used otherwise.
A fixed vector type and a raw general access type would do the
trick, but those could be something that are almost never used outside of interfacing packages.
On 2021-04-20 20:53, Randy Brukardt wrote:
OTOH, an Ada
follow-on would most likely have access types with automatic deallocation as
proposed by Tucker in one of the many AIs on ownership.
So using any form of
explicit deallocation would be discouraged (as would the use of raw pointer types).
I do not understand how that could work, it sounds like a halting
problem to me,
but anyway, where is a problem? Add a whole new hierarchy
of access types independent on the existing one.
In article <s5naeu$r4c$1@gioia.aioe.org>,
"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:
On 2021-04-20 20:53, Randy Brukardt wrote:
OTOH, an Ada
follow-on would most likely have access types with automatic deallocation as
proposed by Tucker in one of the many AIs on ownership.
who is Tucker, and where can i read him, please? :-)
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 379 |
Nodes: | 16 (2 / 14) |
Uptime: | 44:33:39 |
Calls: | 8,141 |
Calls today: | 4 |
Files: | 13,085 |
Messages: | 5,858,054 |