comp.lang.ada
 help / color / mirror / Atom feed
From: gautier_niouzes@hotmail.com
Subject: Re: Ada and string literals
Date: Fri, 1 Feb 2013 13:16:53 -0800 (PST)
Date: 2013-02-01T13:16:53-08:00	[thread overview]
Message-ID: <e7efcb18-9a42-483a-8c97-5c7010e2170d@googlegroups.com> (raw)
In-Reply-To: <ea721d9c-7f42-4908-9787-ef8b8242428a@googlegroups.com>

Le mercredi 30 janvier 2013 17:52:32 UTC+1, codeallergy a écrit :

> another question: how free a object from a procedure ?

with Ada.Unchecked_Deallocation;
...
  procedure Free is new Ada.Unchecked_Deallocation(String, String_Access);

> example:
> procedure Free_Abc (Target : access String)
> is
> begin
>    GNAT.Strings.Free(Target); -- error
> end Free_Abc;
> 
> this code produce the error: actual for "X" must be a variable
> 
> why disallow that ?

The access parameter seems to be like an "in" parameter and treated as a local constant (only a guess, I don't use access parameters).
What you pass as an "in" parameter is not certainly a variable
You could have a call like Free_Abc(null);
Similarly you could have

procedure Do_something(x: in Integer) is
begin
  x:= x + 1; -- same error
end;

But with the "in" parameter, you could have a call like
Do_something(1234);
which makes the x:= x + 1 nonsensical.

Cheers
Gautier



  parent reply	other threads:[~2013-02-01 21:16 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-30  0:44 Ada and string literals codeallergy
2013-01-30  7:08 ` Niklas Holsti
2013-01-30 11:50   ` Mart van de Wege
2013-01-30 13:52     ` Niklas Holsti
2013-01-30 16:09       ` Adam Beneschan
2013-02-01  0:54       ` Shark8
2013-02-01  9:03         ` Niklas Holsti
2013-02-01 14:58           ` Shark8
2013-01-30 16:52     ` codeallergy
2013-01-30 17:19       ` Adam Beneschan
2013-01-30 20:02       ` Simon Wright
2013-01-30 20:19         ` Georg Bauhaus
2013-01-30 22:06       ` Robert A Duff
2013-01-30 22:10         ` Jeffrey Carter
2013-01-31  2:23           ` Robert A Duff
2013-01-31 15:49             ` Adam Beneschan
2013-01-31 22:24               ` Robert A Duff
2013-02-01 21:16       ` gautier_niouzes [this message]
2013-02-02  1:55       ` Stephen Leake
2013-02-02 14:30         ` Robert A Duff
2013-01-31  9:20     ` ake.ragnar.dahlgren
2013-01-30 16:20   ` Robert A Duff
2013-02-01 13:20     ` Stephen Leake
2013-02-01 14:49       ` Robert A Duff
2013-02-01 17:23       ` Dmitry A. Kazakov
2013-02-01 20:22         ` Robert A Duff
2013-02-01 22:03           ` Dmitry A. Kazakov
2013-01-30 22:54 ` codeallergy
2013-02-01  0:50 ` Shark8
replies disabled

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