Re: GCC 4.0 Ada.Containers Cursor danger.



> Container.Insert ("one", 1);
> Container.Insert ("two", 2);
> Container.Insert ("three", 3);
>
> > Table.Insert (Container, "two", 2222, Cursor, Success);
> > pragma Assert (not Success);
> >
> > -- Delete element "two" independently.
> >
> > Cursor2 := Table.Find (Container, "two");
> > Table.Delete (Container, Cursor2);
> >
> > -- The erroreneous line below do nothing and do not raise any
> > exception.
> >
> > Table.Replace_Element (Cursor, -22222);
>
> Well of course this is erroneous, since the element designated by
> Cursor was deleted in the previous statement!

Matthew,

I know that code have an error. I'm saying that the errors like this is
easy to create, and hard to find. Neither compiler not runtime check
for this errors. So, my point is trying to avoid using cursors, for
safety reasons. The Ada is designed to be safe language, Ada is a
hardly checking operations with access types, it is because we have
Unchecked_Deallocation and Unchecked_Access and Unrestricted_Access for
see, where could be danger. I do not see any "Unchecked_" operations
with a cursors. As I understand all cursors operations is "Unchecked_".
If i have to use cursors, i'm in the danger of errors like this. I'm
sure we could use containers without cursors. ADT doing it with
success.

I would propose to have a Ada.Containers subset without cursors for
safety reasons.

<<> valgrind showing the memory corruption

That's good, since what you did corrupts the memory.>>

Note that there is no way in Ada to currupt memory other then by
Unchecked_ or Unrestricted_ access operations. Ada.Containers introduce
a more "legal" way to do memory curruption. Why Java has so much
popularity. One of the reasons that there is absolutely no way to
currupt memory. I do not like Java for some reasons, but I hope Ada
would not be in the C "freedom" to currupt memory.

> The solution is simple: don't jump out of windows...

Where the "windows" safer in C or in Ada ?

.



Relevant Pages

  • Re: Windows Ada database support.
    ... :> Wrong abstractions in PL/SQL too? ... Is in your opinion PL/SQL better than Ada? ... to "descend" to sequential access or to random access via cursors, ... Indeed RDBMSs have some low level features, ...
    (comp.lang.ada)
  • Re: Amount of copying on returned constant objects
    ... but there isn't any obvious way to do that in Ada. ... I guess then that some reference counting companion type (or maybe making ... Cursors can be tagged if the implementation so choses, ...
    (comp.lang.ada)
  • Re: GCC 4.0 Ada.Containers Cursor danger.
    ... Pointer arithmetic in Ada. ... would be complete set of access routines without cursors, ... Maybe we should review Ada.Containers interface. ... <<You appear to not understand the machine model, ...
    (comp.lang.ada)
  • Re: Windows Ada database support.
    ... Cursors are not an abstraction from the point of view of an Ada ... : Surely, but statistically irrelevant. ...
    (comp.lang.ada)

Quantcast