comp.lang.ada
 help / color / mirror / Atom feed
From: ROGERS@uhcl.CSNET ("Pat Rogers, High Tech Lab")
Subject: (none)
Date: Mon, 22-Sep-86 12:36:00 EDT	[thread overview]
Date: Mon Sep 22 12:36:00 1986
Message-ID: <8609240624.AA15139@ucbvax.Berkeley.EDU> (raw)

Dear Ada language-lawyers,

Here's a question:

Given the following,

    package P is

      type LP is limited private;

      function "="( Left, Right : LP ) return LP;

    private
      type LP is new Integer;
    end P;

Within the body for P."+", care must be taken to avoid a recursive call to 
P."+", via the following conversion:

    package body P is

      function "="( Left, Right : LP ) return LP is
      begin
        return Integer(Left) = Integer(Right);
      end "=";

    end P;

Otherwise it will recursively call itself since there is a visible operator
"=" defined for two parameters of type LP, thus hiding the predefined
operator (see RM 7.4.2/5, last sentence). So, well enough.


Now the question: suppose that LP is actually an access type, rather than 
derived from Integer. So,


    package P is

      type LP is limited private;

      function "="( Left, Right : LP ) return Boolean;

    private

      type LP is access Integer;  -- or access whatever

    end P;


In the body, the above approach cannot be used, since there is no 
conversion or qualification type available. To wit,

    package body P is

      function "="( Left, Right : LP ) return Boolean is
      begin
    	if Left = null then ...

This is a recursive call to P."=" on my compiler (yes, validated).



One could simply do the following (my current approach), 

    begin
      return Left.all = Right.all;  -- null pointer dereference possible
    exception
      when Constraint_Error =>  
        return False;
    end "=";

However, in some situations it may be desirable to check for the null
value rather than relying on Constraint_Error (which might be suppressed later
by another programmer, etc... ). Maybe it is just correct in some particular
application to have two objects of type LP be equal if they are both null. 

In those cases, what can be done ?

Is the compiler correct ?   I've not had time to check it on some others.

Any suggestions will be appreciated.

Thanks !

Pat Rogers
High Tech Lab
University of Houston at Clear Lake

             reply	other threads:[~1986-09-22 16:36 UTC|newest]

Thread overview: 109+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1986-09-22 16:36 "Pat Rogers, High Tech Lab" [this message]
  -- strict thread matches above, loose matches on Subject: below --
1996-07-23  0:00 <None> **
1993-09-01  7:24 (none) N.B. Hedd
1993-01-27 23:32 <none> xim
1993-01-27 23:09 <none> xim
1993-01-27 16:39 <none> xim
1993-01-27 16:29 <none> slava
1993-01-26 23:13 <none> xim
1992-12-04  4:03 (none) Michael Feldman
1992-12-03 16:57 (none) dog.ee.lbl.gov!overload.lbl.gov!agate!linus!linus.mitre.org!news!emery
1992-12-03 15:59 (none) Tuck er Taft
1992-12-03 14:43 (none) dog.ee.lbl.gov!overload.lbl.gov!agate!usenet.ins.cwru.edu!magnus.acs.ohio
1992-04-03 15:57 <none> David Emery
1991-09-20 18:58 <None> cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!usen
1991-06-20 13:18 (none) Eric E. Mays 52202
1991-06-20 13:18 (none) Eric E. Mays 52202
1991-05-27  8:20 (none) Giorgio del rio
1991-05-14 13:35 <None> Ace Stewart
1991-03-26 20:38 (none) Eric E. Mays 52202
1991-02-28 17:50 (none) Giorgio del rio
1991-01-10 16:38 (none) GS-09 Ken McCook;SCDD
1990-09-20 18:21 (none) "John P. Solomond, Director, AJPO"
1990-09-24  8:52 ` (none) Richard A. O'Keefe
1990-08-08 21:12 (none) Jose_Duarte
1990-05-07 18:37 (none) Ken McCook;SCDQ;
1990-02-14 16:43 (none) Dave Williamson
1989-09-02 22:13 (none) cdonalds
1989-09-04  1:43 ` (none) Richard O'Keefe
1989-04-14 11:43 (none) jrovert
1989-04-03 13:23 (none) Norman Cohen
1989-03-09 22:07 (none) Norman Cohen
1989-03-08 13:59 (none) Norman Cohen
1989-03-06 19:20 (none) TSIGLER
1989-03-06 14:49 (none) Javier Romanach / GMV
1989-02-24  0:46 (none) Marie T. Minogue
1989-02-16 17:05 (none) Richard.S.D'Ippolito
1989-01-13 17:11 (none) NCOHEN
1988-11-21 22:34 (none) Mark Nelson
1988-11-07 12:52 (none) gita R. Rajan
1988-10-20 18:40 (none) sdl
1988-09-16  9:51 (none) TVOVERBE
1988-06-03 12:08 (none) Greg Gicca
1988-04-07 20:15 (none) sdl
1988-03-17  1:24 (none) sdl
1988-03-12  2:48 (none) sdl
1988-03-09  3:18 (none) sdl
1988-03-07 15:16 (none) amb
1987-12-23 10:54 (none) CARNAL
1987-09-15 19:39 (none) Alex Blakemore
1987-08-28 15:31 (none) LOUBOUTIN
1987-08-25 16:58 (none) LOUBOUTIN
1987-08-25 16:58 (none) LOUBOUTIN
1987-06-09 17:17 (none) SARX
1987-06-04 16:21 (none) seafac
1987-05-29  4:57 (none) postmaster
1987-05-27  3:03 (none) jklemens
1987-03-14  1:22 (none) CONTR47
1987-01-16 16:24 (none) FRASER
1986-12-21 23:16 (none) diby
1986-09-22 16:36 (none) "Pat Rogers, High Tech Lab"
1986-06-05 19:39 (none) info-ada-request
1986-06-05 12:15 (none) info-ada-request
1986-04-08 14:54 (none) Stephen.Hutchinson
1986-03-16 18:52 (none) info-ada-request
1986-02-03 19:07 (none) GAUSTIN
1985-12-05 21:42 (none) , , 
1985-12-05 20:54 (none) , 
1985-12-05 20:50 (none) info-ada
1985-12-05 17:45 (none) info-ada
1985-12-08 21:08 ` (none) Jay R. Ashworth
1985-12-05 15:46 (none) info-ada
1985-12-05  6:09 (none) info-ada
1985-12-06  1:04 ` (none) info-ada
1985-12-06  1:37 ` (none) info-ada
1985-12-06  1:47 ` (none) info-ada
1985-12-04 18:34 (none) RCONN
1985-12-06  1:02 ` (none) info-ada
1985-12-06  1:32 ` (none) info-ada
1985-12-06  1:46 ` (none) info-ada
1985-12-04 16:41 (none) RCONN
1985-12-06  0:59 ` (none) info-ada
1985-12-06  1:29 ` (none) info-ada
1985-12-06  1:46 ` (none) info-ada
1985-12-04  7:50 (none) , 
1985-12-06  0:47 ` (none) info-ada
1985-12-06  1:13 ` (none) info-ada
1985-12-06  1:44 ` (none) info-ada
1985-12-03 22:07 (none) , 
1985-12-06  0:47 ` (none) info-ada
1985-12-06  1:10 ` (none) info-ada
1985-12-06  1:42 ` (none) info-ada
1985-12-03 11:13 (none) , 
1985-12-06  0:42 ` (none) info-ada
1985-12-06  1:08 ` (none) info-ada
1985-12-06  1:41 ` (none) info-ada
1985-12-03  4:24 (none) info-ada
1985-12-06  0:41 ` (none) info-ada
1985-12-06  1:06 ` (none) info-ada
1985-12-06  1:40 ` (none) info-ada
1985-12-06  1:48 ` (none) info-ada
1985-12-12 22:22   ` (none) info-ada
1985-12-02 20:44 (none) Stachour.CSC_RP
1985-12-06  0:41 ` (none) info-ada
1985-11-29 14:35 Ada Professionalism Document Edward V. Berard
1985-12-04  9:09 ` (none) , 
1985-12-06  0:49   ` (none) info-ada
1985-12-10 11:32     ` (none) info-ada
1985-12-06  1:15   ` (none) info-ada
1985-12-06  1:45   ` (none) info-ada
1985-12-06  5:04   ` (none)??? Dick Dunn
replies disabled

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