comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: gnoga build fails on Mac
Date: Wed, 1 Jul 2020 10:52:03 +0200	[thread overview]
Message-ID: <rdhirj$h5f$1@dont-email.me> (raw)
In-Reply-To: <rdgnog$ej7$1@franka.jacob-sparre.dk>

On 7/1/20 3:09 AM, Randy Brukardt wrote:
> 
> I suppose there could be a compiler bug if Movie_Info is prematurely frozen,
> but I suspect it is much more likely that the code is illegal. GNAT didn't
> enforce this rule until recently (it has recently been catching up with
> newer ACATS tests for newer incompatible rules), so I find it likely that
> the code is wrong.

It's certainly possible that the code is wrong, but if so, I'd like to 
understand why. This is a small demo program for Gnoga, and as Gnoga uses Ada 12 
I wrote it with Ada 12 features. I normally use the previous version of the 
language, so my understanding of the changes in this area may be lacking.

As the code is only 115 lines total, I include it here (long lines may wrap):

-- Demo for DB_Maker: Catalog your extensive collection of BetaMax videotape 
cassettes!
--
-- Copyright (C) 2017 by Jeffrey R. Carter
--
with DB_Maker;
with PragmARC.B_Strings;

procedure Movies is
    subtype Strng is PragmARC.B_Strings.B_String (Max_Length => 100);
    use type Strng;

    type Movie_Info is record
       Title       : Strng;
       Year        : Strng;
       Director    : Strng;
       Writer      : Strng;
       Male_Lead   : Strng;
       Female_Lead : Strng;
    end record;

    function "=" (Left : Movie_Info; Right : Movie_Info) return Boolean is
       (Left.Title = Right.Title and Left.Year = Right.Year and Left.Director = 
Right.Director);

    function "<" (Left : Movie_Info; Right : Movie_Info) return Boolean is
       -- Empty
    begin -- "<"
       if Left.Title /= Right.Title then
          return Left.Title < Right.Title;
       end if;

       if Left.Year /= Right.Year then
          return Left.Year < Right.Year;
       end if;

       return Left.Director < Right.Director;
    end "<";

    subtype Field_Number is Integer range 1 .. 6;

    function Field_Name (Field : in Field_Number) return String is
       -- Empty
    begin -- Field_Name
       case Field is
       when 1 =>
          return "Title";
       when 2 =>
          return "Year";
       when 3 =>
          return "Director";
       when 4 =>
          return "Screenplay";
       when 5 =>
          return "Male Lead";
       when 6 =>
          return "Female Lead";
       end case;
    end Field_Name;

    function Value (Item : in Movie_Info; Field : in Field_Number) return String is
       -- Empty
    begin -- Value
       case Field is
       when 1 =>
          return +Item.Title;
       when 2 =>
          return +Item.Year;
       when 3 =>
          return +Item.Director;
       when 4 =>
          return +Item.Writer;
       when 5 =>
          return +Item.Male_Lead;
       when 6 =>
          return +Item.Female_Lead;
       end case;
    end Value;

    procedure Put (Item : in out Movie_Info; Field : in Field_Number; Value : in 
String) is
       -- Empty
    begin -- Put
       case Field is
       when 1 =>
          Item.Title.Assign (From => Value);
       when 2 =>
          Item.Year.Assign (From => Value);
       when 3 =>
          Item.Director.Assign (From => Value);
       when 4 =>
          Item.Writer.Assign (From => Value);
       when 5 =>
          Item.Male_Lead.Assign (From => Value);
       when 6 =>
          Item.Female_Lead.Assign (From => Value);
       end case;
    end Put;

    package Movie_DB is new DB_Maker (Max_Field_Length => 100,
                                      File_Name        => "Movies",
                                      Field_Number     => Field_Number,
                                      Field_Name       => Field_Name,
                                      Element          => Movie_Info,
                                      Value            => Value,
                                      Put              => Put);
begin -- Movies
    null;
end Movies;
--
-- This is free software; you can redistribute it and/or modify it under
-- terms of the GNU General Public License as published by the Free Software
-- Foundation; either version 2, or (at your option) any later version.
-- This software is distributed in the hope that it will be useful, but WITH
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-- for more details. Free Software Foundation, 59 Temple Place - Suite
-- 330, Boston, MA 02111-1307, USA.

Thanks for any insight you or others can provide.

-- 
Jeff Carter
"Propose to an Englishman any principle, or any instrument, however
admirable, and you will observe that the whole effort of the English
mind is directed to find a difficulty, a defect, or an impossibility
in it. If you speak to him of a machine for peeling a potato, he will
pronounce it impossible: if you peel a potato with it before his eyes,
he will declare it useless, because it will not slice a pineapple."
Charles Babbage
92

  reply	other threads:[~2020-07-01  8:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-21  7:57 gnoga build fails on Mac Roger
2020-06-21  8:41 ` Dmitry A. Kazakov
2020-06-21 11:18   ` Roger
2020-06-21 13:28     ` Dmitry A. Kazakov
2020-06-22  3:15       ` Roger
2020-06-22  5:56         ` Dmitry A. Kazakov
2020-06-22  6:14           ` Roger
2020-06-22 11:37           ` Jeffrey R. Carter
2020-06-22 23:25             ` Roger
2020-06-23 11:27               ` Jeffrey R. Carter
2020-06-29  0:55             ` Randy Brukardt
2020-06-29  8:29               ` Jeffrey R. Carter
2020-07-01  1:09                 ` Randy Brukardt
2020-07-01  8:52                   ` Jeffrey R. Carter [this message]
2020-07-03  0:23                     ` Randy Brukardt
2020-07-03  9:09                       ` Jeffrey R. Carter
2020-07-07 14:41                         ` Shark8
2020-07-07 15:37                           ` Jeffrey R. Carter
2020-06-21 14:24 ` Jeffrey R. Carter
2020-06-21 16:46   ` Simon Wright
replies disabled

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