comp.lang.ada
 help / color / mirror / Atom feed
From: bj.mooremr@gmail.com
Subject: Re: I am leaving Ada :-( because of GNAT bugs
Date: Sat, 9 Dec 2017 00:53:46 -0800 (PST)
Date: 2017-12-09T00:53:46-08:00	[thread overview]
Message-ID: <db611f79-dc7e-4d9c-bd68-eefb1dbcc25a@googlegroups.com> (raw)
In-Reply-To: <p0ari4$djp$1@gioia.aioe.org>

On Thursday, December 7, 2017 at 12:45:11 AM UTC-7, Victor Porton wrote:
> Yet one mysterious bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83310
> 
> I am leaving Ada and try to learn Rust or D, or maybe even code in C# 
> instead.
> 
> I cannot tolerate GNAT bugs anymore.
> 
> For the last bug I simply don't know what is a workaround.
> 
> -- 
> Victor Porton - http://portonvictor.org

I had a look at your sources, and managed to get it to compile with some fiddling. I did not encounter the compiler crash that you ran into, but there were a fair number of syntax errors in your sources.

I am not sure which version of GNAT you are using, GPL for FSF. Both are good quality compilers, but if you are running into compiler bugs in one, it might be worth trying your source in the other. For your source code, I was trying it out with GNAT GPL 2017.

The other point to mention is that it has been my experience that if the compiler is crashing, it generally means I am trying to do something really weird and not allowed in Ada, or doing something allowed but convoluted, or not elegant, and there is a better way to do the same thing.

Here are some of the main problems I found with the source.

1. Many bodies of packages were missing. To get these, I used the "Generate Body", utility from the GPS IDE, which generated most of these. I eventually got it to generate all the bodies, once I fixed the issues below. 

2. For a number of the tagged types, the Parse function had the controlling parameter as the second parameter. I think Ada might allow that, but I generally put the controlling parameter (the one that has the same type as the tagged type), at the beginning as the first parameter. It's a convention I always use, which I think helps readability, if nothing else. It may be that the compiler has better support for name resolution if you follow this convention, but I really dont know, as I never code that way. I tried to look this up in the RM, but couldnt not find a rule that says the controlling parameters need to come first.

3. Parse in Boilder.RDF_Format.Resource.Parser is missing a return statement, and the parameters in the body do not match the ones in the spec.

4. I would not put not overriding clauses on a primitive function that is a root type. If it is a root type, it cant be overriding anything. Having "not overriding" clauses on a root type might be weird enough that the compiler doesn't support that very well. I would get rid of those.

5. In RDF-auxiliary-limited_handled_record, you have a nested generic package, called Common_Handlers where there is a type derived from a generic formal type that is in turn derived from a type of the enclosing package. On the nested type declaration you are overriding the Finalize procedure as a controlled type, but doing that as a rename of a function in the enclosing package. That strikes me as likely something that the compiler might have trouble with. In fact, it was complaining about that line for me, but gave a compiler error, not a crash.
I fixed that by not declaring as a rename, but making it an actual procedure, then having that call the other function of the enclosing package in the body of Finalize.

6. In RDF.Raptor.Term, There are 3 subtypes declared of a tagged type, before all the primitive functions of the tagged type were declared. That might be OK, but I'd be concerned about freezing rules, and in any case, I think it is better form and more readable to move the subtype declarations down further to after all the primitive functions of the tagged type that they are subtypes of have been declared.

7. In the same area, you declare a subtype of an access type declared in another package, then try to override a primitive of a type from that other package, but using the subtype declared in the new package. I believe you need exact matching on the subtypes passed to the overridden package, for non-controlling parameters, which means you should declare your overriden function using the access type declared in the original package.

8. You have several places where you declare a subtype with Dynamic_Predicates

eg. subtype URI_Term_Type_Without_Finalize is Term_Type_Without_Finalize
     with Dynamic_Predicate => Is_URI(URI_Term_Type_Without_Finalize);

where Is_URI is a primitive function of the tagged type. I am not sure if it is legal to do it that way, but GNAT did not like this. I would use object prefix notation, which I think is more readable in this case and makes it more obvious that Is_URI is a primitive of the type. ie.

subtype URI_Term_Type_Without_Finalize is Term_Type_Without_Finalize
     with Dynamic_Predicate => URI_Term_Type_Without_Finalize.Is_URI;

GNAT is happy if you do it this way.

9. In rdf-redland-query_results.ads, you declare a type derived from a tagged type, but then try to apply a Pre'Class aspect. This apparently is not legal, though the GPL 2016 compiler doesn't complain. I ran into this, with my own code, that GPL 2017 told me with a compiler error that the code was not legal.

Pre'Class can only be applied to a root type apparently.

To fix that, change Pre'Class => to just Pre => 

That might be the issue that is actually causing the compiler to crash, if you are using the FSF GNAT. It might not have this check yet, and might have trouble generating the code.

Once I made these changes, the sources compiled. I had to create my own main program, because I couldn't see a main in your sources, nor did I see a project file, so I created a simple one from scratch.

Hopefully this will get you to reconsider your decision to leave Ada. 
I have done a little bit in Rust, and considerably more in C#.
 
For me, Ada is still by far the best choice, but you can come to your own conclusions. :-) 

Brad

  parent reply	other threads:[~2017-12-09  8:53 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-07  7:45 I am leaving Ada :-( because of GNAT bugs Victor Porton
2017-12-07  9:54 ` Simon Wright
2017-12-09  8:53 ` bj.mooremr [this message]
2017-12-09  9:35   ` Simon Wright
2017-12-11 22:47     ` Randy Brukardt
2017-12-12 19:43   ` jm.tarrasa
2017-12-12 20:50     ` Dmitry A. Kazakov
2017-12-12 21:15     ` Paul Rubin
2017-12-13  7:01       ` Luke A. Guest
2017-12-13 17:46         ` Jeffrey R. Carter
2017-12-13 19:37           ` Jacob Sparre Andersen
2017-12-13 21:52             ` Jeffrey R. Carter
2017-12-14 12:54               ` Lucretia
2017-12-14 12:52           ` Lucretia
2017-12-14 13:44             ` Dmitry A. Kazakov
2017-12-14 14:53               ` MM
2017-12-14 16:43                 ` Luke A. Guest
2017-12-14 19:37                   ` MM
2017-12-14 17:01             ` Jeffrey R. Carter
2017-12-15 21:52         ` Paul Rubin
2017-12-12 22:57 ` Mehdi Saada
2017-12-13  6:43   ` Per Sandberg
2017-12-13  7:01   ` Luke A. Guest
2017-12-13  8:03   ` G. B.
2017-12-13  9:06     ` Dmitry A. Kazakov
2017-12-13 17:41   ` Jeffrey R. Carter
replies disabled

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