package https://url.uk.m.mimecastprotect.com/s/mfqZCKZXXu2v186rCva9xD?domain=geometry.io
from MagicMoments from the “Programming in Ada 2022”. BTW: strange enough that a program in a book on programming doesn’t compile in the presented form. N.B.: In Ada, from this author. Probably this is left as an exercise to the reader.
It seems just a technical error in some part of the publishing process.
You can fix it, the package is Geometry.IO
. Do this, for example:
wget https://www.cambridge.org/files/5617/1654/7225/MagicMoments.txt
sed -i 's%https://url.uk.m.mimecastprotect.com/s/mfqZCKZXXu2v186rCva9xD?domain=geometry.io%Geometry.IO%' MagicMoments.txt
gnatchop MagicMoments.txt
gprbuild magic_moments.adb
P.S. The error consists, probably, in some program that has processed the text and has converted Geometry.IO
in a URL, simply because .io is a domain. I’ve seen the same happens here if you don’t quote it as code: Geometry.IO
Geometry.IO
that’s clear - the actual book says so. Still annoying enough. I’m probably the only one who has downloaded the code so far Now you even have to reverse engineer code examples. You have to cut all that stuff apart anyway and put it into a neat shape - which, as I said, is incomprehensible to me in a programming book.
Well, not really… at least, it’s not a language limitation.
GNAT itself is limited, in its implementation, in that GNAT cannot have multiple compilation units in a single file.
Well, undoubtedly. I cut it into pieces:
build_list.adb
geometry-circles.adb
geometry-circles.ads
geometry-io.adb
geometry-io.ads
geometry-lists.adb
geometry-lists.ads
geometry-magic.adb
geometry-magic.ads
geometry-points.adb
geometry-points.ads
geometry-squares.adb
geometry-squares.ads
geometry-triangles.adb
geometry-triangles.ads
geometry.adb
geometry.ads
magic_moments.adb
tabulate_properties.adb
…with a little bit perl: perl -ne 'next if /^--/; print' src/magic_moments.adb > src/tabulate_properties.adb
a.s.o.
The result runs flawless - as expected.
I expected runnable examples at least on the examples page of a book.
Somewhere in the book the author mentions that single listings are used to safe space.
But this “debate” leads to nowhere - and this forum is the wrong place. The community is not responsible for the layout etc. of the book.
If you’re using GNAT, you already have a tool from the toolchain to split source code in the way required by GNAT. As I showed you, It’s as simple as:
gnatchop MagicMoments.txt
With other compilers, they probably either have a similar tool, or accept the source text as a single file.
Programming in Ada 2022 by Barnes covers the Ada language as defined by ISO, it is not about a specific toolchain. If you’re using GNAT, a good complementary resource will be: Introduction to the GNAT Toolchain — learn.adacore.com
Edit: reference to gnatchop in that tutorial: GNAT Tools — learn.adacore.com
Precious hint - nice tool. Thanks.
I notified the author and he was somewhat horrified that the files had been altered after he sent them to the publisher. I presume he will get them fixed up shortly.
And yes, you will need to use “gnatchop” (or “gnatname”) whenever you want to use GNAT to compile an Ada source file with multiple compilation units. See Handling a file with multiple units
PTC’s ObjectAda and Green Hills’ AdaMulti don’t have such a requirement, though they don’t support as many of the newer language features as does GNAT.
I finally downloaded all of the additional resources for the Barnes 2022 book. Almost all of the bundled programs had errors during gnatchop that implied (not yet verified) instances of illegal Ada code. Will try to verify tomorrow. When I complete verifying, should I document what I found here?
RBE
yes, it would help others if you document your findings. Thank you!
It looks like an overzealous email security tool has replaced all instances of things that might be domain names with an indirect link through their scanner.
e.g. Geometry.IO
get interpreted as a DNS name/link, and rewritten as: https://url.uk.m.mimecastprotect.com/s/mfqZCKZXXu2v186rCva9xD?domain=geometry.io%Geometry.IO%
My employer uses something similar, and the redirect often breaks links in verification emails .
Interestingly, Discourse (the forum software) also interprets Geometry.IO
as a DNS name, if not quoted in backticks.
I informed John Barnes of one such problem, and I would be happy to forward to him any further specific errors that have cropped up. John is generally very careful, and so this is almost certainly part of the final production process at the publisher that went astray.
Barnes 2022 Ada Book Additional Resource downloads with embedded URL(s):
Summary of URL(s) being embedded in source bundle text files:
find . -type f -name '*.txt' -exec ggrep -n -H mimecastprotect {} \;
./Programs/PlayingPools/PlayingPools.txt:76: if https://url.uk.m.mimecastprotect.com/s/HheECJqDDiqrXzVmuVfGTyiqC7?domain=pool.free < SISE then
./Programs/PlayingPools/PlayingPools.txt:86: https://url.uk.m.mimecastprotect.com/s/HheECJqDDiqrXzVmuVfGTyiqC7?domain=pool.free := https://url.uk.m.mimecastprotect.com/s/HheECJqDDiqrXzVmuVfGTyiqC7?domain=pool.free - SISE;
./Programs/PlayingPools/PlayingPools.txt:110: https://url.uk.m.mimecastprotect.com/s/HheECJqDDiqrXzVmuVfGTyiqC7?domain=pool.free := https://url.uk.m.mimecastprotect.com/s/HheECJqDDiqrXzVmuVfGTyiqC7?domain=pool.free + SISE;
./Programs/PlayingPools/PlayingPools.txt:141: https://url.uk.m.mimecastprotect.com/s/HheECJqDDiqrXzVmuVfGTyiqC7?domain=pool.free := Pool.Size;
./Programs/PlayingPools/PlayingPools.txt:233: https://url.uk.m.mimecastprotect.com/s/TPO-CKZXXu2EJw6vSvhvT5qLZA?domain=s.top := https://url.uk.m.mimecastprotect.com/s/TPO-CKZXXu2EJw6vSvhvT5qLZA?domain=s.top + 1;
./Programs/PlayingPools/PlayingPools.txt:240: https://url.uk.m.mimecastprotect.com/s/TPO-CKZXXu2EJw6vSvhvT5qLZA?domain=s.top := https://url.uk.m.mimecastprotect.com/s/TPO-CKZXXu2EJw6vSvhvT5qLZA?domain=s.top - 1;
./Programs/PlayingPoolsPlus/PlayingPoolsPlus.txt:74: if https://url.uk.m.mimecastprotect.com/s/HheECJqDDiqrXzVmuVfGTyiqC7?domain=pool.free < SISE then
./Programs/PlayingPoolsPlus/PlayingPoolsPlus.txt:84: https://url.uk.m.mimecastprotect.com/s/HheECJqDDiqrXzVmuVfGTyiqC7?domain=pool.free := https://url.uk.m.mimecastprotect.com/s/HheECJqDDiqrXzVmuVfGTyiqC7?domain=pool.free - SISE;
./Programs/PlayingPoolsPlus/PlayingPoolsPlus.txt:108: https://url.uk.m.mimecastprotect.com/s/HheECJqDDiqrXzVmuVfGTyiqC7?domain=pool.free := https://url.uk.m.mimecastprotect.com/s/HheECJqDDiqrXzVmuVfGTyiqC7?domain=pool.free + SISE;
./Programs/PlayingPoolsPlus/PlayingPoolsPlus.txt:139: https://url.uk.m.mimecastprotect.com/s/HheECJqDDiqrXzVmuVfGTyiqC7?domain=pool.free := Pool.Size;
./Programs/PlayingPoolsPlus/PlayingPoolsPlus.txt:274: https://url.uk.m.mimecastprotect.com/s/TPO-CKZXXu2EJw6vSvhvT5qLZA?domain=s.top := https://url.uk.m.mimecastprotect.com/s/TPO-CKZXXu2EJw6vSvhvT5qLZA?domain=s.top + 1;
./Programs/PlayingPoolsPlus/PlayingPoolsPlus.txt:281: https://url.uk.m.mimecastprotect.com/s/TPO-CKZXXu2EJw6vSvhvT5qLZA?domain=s.top := https://url.uk.m.mimecastprotect.com/s/TPO-CKZXXu2EJw6vSvhvT5qLZA?domain=s.top - 1;
./Programs/SuperSieve/SuperSieve.txt:238: if https://url.uk.m.mimecastprotect.com/s/CGE-COyllcpRGXM9c5uATGLhOP?domain=c.im /= 0 then
./Programs/SuperSieve/SuperSieve.txt:239: Put(" + "); Put(https://url.uk.m.mimecastprotect.com/s/CGE-COyllcpRGXM9c5uATGLhOP?domain=c.im, 0); Put('i');
./Programs/SylvanSorter/SylvanSorter.txt:73: -- Note the conversion required to convert the component https://url.uk.m.mimecastprotect.com/s/o5QgCMQDDfqOl870uWs3T8dZpN?domain=l.next
./Programs/SylvanSorter/SylvanSorter.txt:77: L := List(https://url.uk.m.mimecastprotect.com/s/o5QgCMQDDfqOl870uWs3T8dZpN?domain=l.next);
./Programs/SylvanSorter/SylvanSorter.txt:94: while https://url.uk.m.mimecastprotect.com/s/AMDtCN9DDH0lRxzrsrtkTyT3E-?domain=local.next /= null loop
./Programs/SylvanSorter/SylvanSorter.txt:97: https://url.uk.m.mimecastprotect.com/s/AMDtCN9DDH0lRxzrsrtkTyT3E-?domain=local.next := Second;
./Programs/MagicMoments/MagicMoments.txt:263:package https://url.uk.m.mimecastprotect.com/s/GiHyCL866TRjvO7ptPiOTy6P2f?domain=geometry.io is
./Programs/MagicMoments/MagicMoments.txt:281:package body https://url.uk.m.mimecastprotect.com/s/GiHyCL866TRjvO7ptPiOTy6P2f?domain=geometry.io is
Of course this causes gnatchop to go nuts…
Of course this causes gnatmake failures…
I have more details regarding gnatchop output and gnatmake output, but I think that it is not necessary to provide that much detail (unless someone wants me to deliver that as well).
Regards,
RBE
Hilariously bad.
Makes one reasses his expectations for Cambridge University Press.
They don’t even offer an errata form on the book’s page.
It’s indeed a discredit to the publisher, but can be easily solved. Using, for example, the MagicMoments.txt URL that was published at the beginning, this GNU sed command-line will fix it, so the GNAT toolchain can be applied:
wget https://www.cambridge.org/files/5617/1654/7225/MagicMoments.txt
sed -i 's%https://url.uk.m.mimecastprotect.com/s/[a-zA-Z0-9]*?domain=%%' MagicMoments.txt
gnatchop MagicMoments.txt
gprbuild magic_moments.adb
The same command should fix the other instances present on the other programs in @Ret_Build_Engineer’s check.