My gcc 14.1.0 GNAT compiler complains about the above:
totient.adb:53:43: warning: wrong length for array of subtype of “Standard.String” defined at line 38 [enabled by default]
totient.adb:53:43: warning: Constraint_Error will be raised at run time [enabled by default]
totient.adb:53:59: warning: wrong length for array of subtype of “Standard.String” defined at line 38 [enabled by default]
totient.adb:53:59: warning: Constraint_Error will be raised at run time [enabled by default]
I can change this using Ada string slices without using rename…but I wonder if someone could show me what the author intended with the rename that would also compile. Is this something that would have compiled under Ada 95 or Ada 83?
The current GNAT Pro has a much better error here:
foo.ads:5:49: warning: static range out of bounds of subtype of "Standard.Integer" defined at line 2 [enabled by default]
foo.ads:5:49: warning: Constraint_Error will be raised at run time [enabled by default]
where line 5 is using “17” when the string only has 15 characters, so the error is legitimate.
That said, it would be much better to use 'First and 'Last for indexes
Impossible with the version he posted (in this case it’s wrong from the first version).
I’ve made the fixes and some improvements in Rosseta, and it now prints the same output as posted (case insensitively, since I’ve used True'Image and False'Image. It could probably be improved further, if you want to continue.
Thank you for the code improvement of this task on the Rosetta Code web site. I don’t see the need for additional changes. It is great to have code that works…
One request (if it is ok to request, apologies if not) is that when you post up code snippets to use the code delimiters. You can use triple back ticks: ``` before and after the code to get nicely formatted code (and compiler output as well, see ebriot’s above post). That can really help us out by making it much easier to read. EX:
And if you do the compiler results as well, they come out to be:
totient.adb:53:43: warning: wrong length for array of subtype of “Standard.String” defined at line 38 [enabled by default]
totient.adb:53:43: warning: Constraint_Error will be raised at run time [enabled by default]
totient.adb:53:59: warning: wrong length for array of subtype of “Standard.String” defined at line 38 [enabled by default]
totient.adb:53:59: warning: Constraint_Error will be raised at run time [enabled by default]
It makes seeing the line numbers and such much easier.
The back tick key is usually just left of the 1 key I think.