From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!paganini.bofh.team!newsfeed.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: gnoga build fails on Mac Date: Thu, 2 Jul 2020 19:23:38 -0500 Organization: JSA Research & Innovation Message-ID: References: <4bbbd09e-e14f-46f5-a510-bdf0c17eba8fo@googlegroups.com> <57adcbd8-4583-4c0f-8bdf-1ac8bd6c6913o@googlegroups.com> Injection-Date: Fri, 3 Jul 2020 00:23:39 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="31913"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader01.eternal-september.org comp.lang.ada:59318 List-Id: A body is always freezing; an expression function is freezing if it is a completion. So that would suggest that this particular case should be legal. But I wouldn't want to insist that a compiler writer get this case right, because of interaction between types and primitive operations when not declared in a package. About the only time it makes sense to declare a type in a procedure like this is to write simple test/example programs - which necessarily makes those tests/examples less realistic than they should be. So forcing implementers to spend a lot of time on corner cases for these sorts of declarations. If I was designing a simpler Ada-like language, I'd completely ban declaring types outside of packages, so that the rules for primitive operations and overriding would be the same for all types. (I'd also ban declaring packages that aren't at library level, which would get rid of the majority of accessibility checking and similar nonsense.) The only time anyone would miss it would be when writing simple test programs. Not a huge loss. Randy. "Jeffrey R. Carter" wrote in message news:rdhirj$h5f$1@dont-email.me... > 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