comp.lang.ada
 help / color / mirror / Atom feed
From: "Mark Lundquist" <mark@rational.com>
Subject: Re: type mismatches/access type
Date: Wed, 07 Mar 2001 23:38:36 GMT
Date: 2001-03-07T23:38:36+00:00	[thread overview]
Message-ID: <0Ezp6.524605$U46.15715798@news1.sttls1.wa.home.com> (raw)
In-Reply-To: wKxo6.7148$t21.173574@news3.oke.nextra.no


Frank <franjoe@frisurf.no> wrote in message
news:wKxo6.7148$t21.173574@news3.oke.nextra.no...
> Hi!
>
> I have downloaded the source code for the ADEPT projekt (on AdaPower
> w-page).
> There is a package  that is a part of the "jxtrans" program
> in there that I get a compilation error on, code snippet (of what I
believe
> is
> important :-) follows:
> The compiler is very frustrated by the use of the "=" operator and
>

Yes, and it doesn't like assignment either (and rightly so).

[...]
>
> Is there some way to convince the compiler that Element can be "null"?

Well, that's just it... Element can't be null!  :-)  Null does not exist for
anonymous access types, such as defined by an access parameter.

First of all: delete the if statements that deal with "if Element = null".
They're meaningless and illegal, and there's no way to make them meaningful
or legal, and they wouldn't do you any good if there were.  The call to the
subprogram involves an implicit conversion from the type of the actual
parameter value to the anonymous type of the access parameter, so if you
tried to pass a null access value as the actual parameter, the conversion
will raise Constraint_Error (since null does not exist for the type you're
converting to.

Second: look at the places where you are assigning the value of an access
parameter to an object of a named access type (I think something like
"List.Head := Element" in your example).  You need a conversion to make this
legal, e.g.

    List.Head := Element_P (Element);

or whatever.

> after all,the package has compiled on Solaris...

Thirdly: if you mean that you compiled it successfully, then take that
compiler and throw it away!

Fourthly: get rid of those annoying '('...')' around the expressions in the
"if" statements.


Hope this helps!

Mark Lundquist
Rational Software






  parent reply	other threads:[~2001-03-07 23:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-04 20:35 type mismatches/access type Frank
2001-03-04 20:43 ` Additional info for the message above: for Linux/RedHat6.2/Gnat3.13 Frank
2001-03-07 21:55 ` Still open for suggestions :-) Frank
2001-03-07 23:38 ` Mark Lundquist [this message]
2001-03-08  6:24   ` type mismatches/access type Frank
replies disabled

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