comp.lang.ada
 help / color / mirror / Atom feed
* Is this correct?
@ 1996-05-02  0:00 W. Wesley Groleau (Wes)
  0 siblings, 0 replies; only message in thread
From: W. Wesley Groleau (Wes) @ 1996-05-02  0:00 UTC (permalink / raw)



I'm not saying where this comes from.  If you know, please
keep it to yourself and certainly don't flame the author.

It seems to me that the following won't work.  Or are the
comments (all added by me) inaccurate?


  function "="(Left : Stack; Right : Stack) return Boolean is

   LC    : Container_Pointer := Left.Head ;   -- what if either
   RC    : Container_Pointer := Right.Head ;  -- is null before call?
   Equal : Boolean := True ;                 -- (caller gets exception)

  begin -- "="

    loop

      Equal := LC.Value = RC.Value ;

      LC := LC.Next ;
      RC := RC.Next ;

      exit when (LC = null or RC = null) or not Equal ;
      -- I suspect a typo because parentheses are unnecessary
      -- If top three items are equal, but only Right has a fourth, then
      -- exit because LC = null and return True (incorrect).

    end loop ;

    return Equal ;

  end "=";




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1996-05-02  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-05-02  0:00 Is this correct? W. Wesley Groleau (Wes)

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