<<

To receive the Ada User Journal, apply to Ada-Europe at: http://www.ada -europe.org/join ADA Volume 41 USER Number 4 December 2020

JOURNAL Contents Page Editorial Policy for Ada User Journal 192 Editorial 193 Quarterly News Digest 195 Conference Calendar 224 Forthcoming Events 232 Special Contribution P. Rogers “From Ada to Platinum SPARK: A Case Study” 235 Proceedings of the "HILT 2020 Workshop on Safe Languages and Technologies for Structured and Efficient Parallel and Distributed/Cloud Computing" T. Taft “A Layered Mapping of Ada 202X to OpenMP” 251 J. Verschelde “Parallel Software to Offset the Cost of Higher Precision” 255 Puzzle J. Barnes “Shrinking Squares and Colourful Cubes” 261 In memoriam: William Bail 263 Ada-Europe Associate Members (National Ada Organizations) 264 Ada-Europe Sponsors Inside Back Cover

Ada User Journal Volume 41, Number 4, December 2020 195 Quarterly News Digest

Alejandro R. Mosteo Centro Universitario de la Defensa de Zaragoza, 50090, Zaragoza, Spain; Instituto de Investigación en Ingeniería de Aragón, Mariano Esquillor s/n, 50018, Zaragoza, Spain; email: [email protected]

as far as when Ada prototypes had - A layered mapping of Ada 202X parallel parentheses for subprograms without constructs to OpenMP (Tucker Taft), Contents arguments. - Experience integrating FAA's NextGen To conclude, during this period also took ERAM (mostly Ada) with SWIM Preface by the News Editor 195 place the Advent of Code, a scored (Mixed languages) (Brian Kleinke, Ada-related Events 195 competition in which a programming Leidos) Ada and Education 196 puzzle a day is presented for you to solve Ada-related Resources 196 - A highly parallel multiple double in your favorite language. A few members precision polynomial solver framework Ada-related Tools 197 of c.l.a. took the bait and this led to some Ada-related Products 199 in Ada (PHC Pack - Prof. Jan interesting exchanges of ideas around the Verschelde of UoI at Chicago) Ada and Operating Systems 200 solutions in a large number of threads Ada and Other Languages 201 which I have strived to summarize for you - A cloud-native/HPC-centric Ada Practice 202 [5]. hyperscaling framework for Ada, and a Obituary 221 supporting Ada-specific exokernel OS Sincerely, (Yours truly) Alejandro R. Mosteo. [Messages without subject/newsgroups Please check out the workshop's website are replies from the same thread. [1] “Tragic News about Vinzent Hoefler”, (https://2020.splashcon.org/home/ Messages may have been edited for minor in Obituary. hilt-2020) if you are interested in proofreading fixes. Quotations are [2] “Logging and Protected Actions”, in attending. trimmed where deemed too broad. Ada Practice. Sender’s signatures are omitted as a [3] “Starting time of Real-time Clock”, in CfC 25th Ada-Europe Conf. general rule. —arm] Ada Practice. on Reliable Software [4] “Ada Syntax Questions”, in Ada Technologies Preface by the News Practice. From: Dirk Craeynest Editor [5] “Advent of Code” and “Advent of Code Thread Compilation”, in Ada Subject: CfC 25th Ada-Europe Conf. on Dear Reader, Practice. Reliable Software Technologies As I write these lines I have the FOSDEM Date: Sun, 6 Dec 2020 11:39:55 -0000 livestream on my second monitor. This Newsgroups: comp.lang.ada, brings me to the first topic that I want to Ada-related Events fr.comp.lang.ada,comp.lang.misc highlight in this issue: sadly, during last ACM HILT 2020 at [CfC is included in the Forthcoming quarter we knew [1] of the passing of Events Section —arm] fellow Adaist Vinzent “Jellix” Höfler. I SPLASH 2020 “devirtualized” him precisely at Ada-Europe 2021 FOSDEM’20, where he cracked a joke [Event already in the past, for the record. during my demo that was producing lots —arm] Conference - Extended 14 of “No C sources found in this project” From: Richard Wai January Deadline warnings. To this, he had to say (filtered by my memory): “I don’t see the Subject: ACM HILT 2020 (High Integrity From: Dirk Craeynest problem.” Language Technologies) at SPLASH 2020 - Nov 16 & 17 Subject: Ada-Europe 2021 Conference - As for regular discussions, this time EXTENDED 14 January deadline around I selected a few interesting and Date: Sun, 1 Nov 2020 19:56:24 -0800 Newsgroups: comp.lang.ada Date: Thu, 31 Dec 2020 15:54:46 -0000 sometimes amusing heated debates. We Newsgroups: comp.lang.ada, have a couple of technical rabbit holes, Hey everyone, just a reminder that the 6th fr.comp.lang.ada,comp.lang.misc about the finer details of protected actions HILT workshop this year is on Nov 16 & syntax (that started from an innocent- 17, and is part of the larger SPLASH The Ada-Europe 2021 Conference looking question about logging [2]) and 2020 conference (2020.spashcon.org). organizers decided to provide more time properties of real-time clocks and Unsurprisingly, this year's workshop will for authors to prepare their contributions. durations [3]. Did you know that be fully virtual. The deadline for most submissions is Duration’Range can legally be as short as extended to Thursday 14 January 2020. a day? I am a bit ashamed to admit I did HILT 2020 focuses on the growing 2 weeks remain! not. Also, an often-seen observation about importance of large-scale, highly parallel, [CfC is included in the Forthcoming array indexing syntax from an Ada distributed and/or cloud applications. Events Section —arm] newcomer led to many strongly-held For Ada specifically, we have talks on: opinions on the merits (or lack thereof) of some aspects of Ada syntax [4] that led us

Ada User Journal Volume 41, Number 4, December 2020 196 Ada-related Resources

Happy Birthday, Lady Ada >> There's nothing wrong with using - Telegram: 108 (+18) users [6] integer to start off and then moving - Twitter: 60 (-7) tweeters [7] From: AdaMagica onto defined types. 95 (+3) unique tweets [7] > Yes there is! (see my paper at the last Subject: Happy birthday, Lady Ada [1] https://www.linkedin.com/groups/ Ada-Europe). The first message when 114211/ Date: Wed, 9 Dec 2020 19:00:53 -0800 you teach Ada is that it is all about Newsgroups: comp.lang.ada defining proper types. You have to start [2] http://www.reddit.com/r/ada/ Primeval times when Babbage dwelt: by fighting bad habits from other [3] http://stackoverflow.com/questions/ languages. tagged/ada not were bit nor byte One of the most difficult things for [4] https://netsplit.de/channels/ nor operating system, programmers to graft these days is the details.php?room=%23ada& concept and proper use of types, which is net=freenode not hardware below key to Ada. Ada makes this even more [5] https://gitter.im/ada-lang nor above software, complicated with the very useful attributes of private and limited types. [6] https://t.me/ada_lang abyss abundant, Unless a text clearly conveys the use of [7] http://bit.ly/adalang-twitter but computer nowhere. types and illustrates it throughout, it is useless for teaching people Ada. Since Repositories of Open Source And lo, there was Ada, this is a foreign concept to most current programmers, illustrations and good Software and Ada separated the numbers exercises are needed, too. From: Alejandro R. Mosteo and split them, Compare this text to Barnes, which most in Zero and One did she split them. of us use as a quick reference. Subject: Repositories of Open Source software Continuation see: From: Shark8 Date: Mon, 02 Nov 2020 18:41:21 +0100 https://www.ada-deutschland.de/sites/ To: Ada User Journal readership default/files/AdaTourCD/AdaTourCD Date: Thu, 12 Nov 2020 13:24:57 -0800 2004/Ada%20Magica/20. Rosetta Code: 761 (+14) examples [1] > So I can't learn Ada from docs online? 37 (=) developers [2] From: Simon Wright You can. But the best Ada resources are GitHub: 755 (+26) developers [3] books and the Language Reference. Date: Thu, 10 Dec 2020 10:08:56 +0000 Sourceforge: 278 (+2) projects [4] (The Language Reference is dry, but very > in Zero and One did she split them. readable compared to some of the other Open Hub: 212 (=) projects [5] The Analytical Engine was a decimal standards I've come across.) Alire: 146 (+16) crates [6] machine Also, the compiler itself is typically very From: AdaMagica good because of generally high-quality Bitbucket: 88 (-2) repositories [7] error messages. Codelabs: 52 (=) repositories [8] Date: Thu, 10 Dec 2020 02:52:06 -0800 From: Chris Townley AdaForge: 8 (=) repositories [9] > The Analytical Engine was a decimal machine Date: Thu, 12 Nov 2020 22:31:59 +0000 [1] http://rosettacode.org/wiki/ Category:Ada That's OK. > Also, the compiler itself is typically very good because of generally high- [2] http://rosettacode.org/wiki/ I know Babbage's engine came before quality error messages. Category:Ada_User Zuse, C++ came after Ada. Although the errors can be very confusing [3] https://github.com/search? But an ode need not be historically sometimes, if you make a big mistake… q=language%3AAda&type=Users correct. Would you claim Edda is [4] https://sourceforge.net/directory/ historically correct? language:ada/ Ár var alda, þat er Ymir bygði, Ada-related Resources [5] https://www.openhub.net/tags? Vara sandr né sær né svalar unnir; [Delta counts are from Nov 2nd to Feb names=ada iorð fannz æva né upphiminn, 2nd. —arm] [6] https://alire.ada.dev/crates.html gap var ginnunga, enn gras hvergi. [7] https://bitbucket.org/repo/all? Translate this and it will give about the Ada on Social Media name=ada&language=ada same as the first verse above. From: Alejandro R. Mosteo [8] https://git.codelabs.ch/? a=project_index Ada and Education Subject: Ada on Social Media [9] http://forge.ada-ru.org/adaforge Date: Tue, 02 Feb 2021 17:31:21 +0100 Strategies for Teaching Ada To: Ada User Journal readership Language Popularity Ada groups on various social media: [Cont. from “Strategies for Teaching Rankings - LinkedIn: 3_078 (+53) members [1] Ada” in AUJ 41-2, June 2020 —arm] From: Alejandro R. Mosteo From: Norman Worth - Reddit: 5_233 (+513) members [2] - Stack Overflow:1_973 (+49) Subject: Ada in language popularity Subject: Re: Beginning Ada Programming, questions [3] rankings by Andrew T. Shvets (2020) Date: Mon, 20 Jul 2020 09:38:21 +0100 - Freenode: 85 (-5) users [4] Date: Mon, 2 Nov 2020 14:14:03 -0700 To: Ada User Journal readership Newsgroups: comp.lang.ada - Gitter: 66 (+2) people [5]

Volume 41, Number 4, December 2020 Ada User Journal Ada-related Tools 197

[Positive ranking changes mean to go up OpenDocument files, MS Office 2007+, - An exception-free variant of Put was in the ranking. The IEEE ranking has Chrome extensions, Mozilla added to the Generic_Indefinite_FIFO published its 2020 edition. —arm] extensions, E-Pub documents and many package; - TIOBE Index: 32 (+7) 0.4% others - ModBus TCP/IP implementation bug fix (+0.05%) [1] - task safety: this library can be used ad (the package - PYPL Index: 19 (=) 0.65% (+0.3%)[2] libitum in parallel processing GNAT.Sockets.Connection_State_Mach ine.MODBUS_Client); - IEEE Spectrum (general): 39 43 (+4) - endian-neutral I/O Score: 32.8 24.8 [3] - Code modified to work around GCC Main site & contact info: 10.0.1 optimization bug. - IEEE Spectrum (embedded): 12 13 (+1) http://unzip-ada.sf.net Score: 32.8 24.8 [3] Simple Components v4.53 [1] https://www.tiobe.com/tiobe-index/ Project site & subversion repository: From: Dmitry A. Kazakov https://sf.net/projects/unzip-ada/ [2] http://pypl.github.io/PYPL.html [3] https://spectrum.ieee.org/static/ GitHub clone with git repository: Subject: ANN: Simple components v4.53 interactive-the-top-programming- Date: Sun, 13 Dec 2020 10:02:03 +0100 languages-2020 https://github.com/zertovitch/zip-ada Newsgroups: comp.lang.ada GNAT CE 2020, arm-eabi, [...] Ada-related Tools for macOS Changes to the previous version: -Ada v.57 From: Simon Wright - Get_Reader_Timeout, Set_Reader_Timeout, Wait_For_Tasks From: [email protected] Subject: GNAT CE 2020, arm-eabi, for were added to the package Subject: Ann: Zip-Ada v.57 macOS GNAT.Sockets.Server.Blocking; Date: Fri, 2 Oct 2020 09:57:42 -0700 Date: Tue, 06 Oct 2020 16:59:05 +0100 - JSON parser fixed to accept empty Newsgroups: comp.lang.ada Newsgroups: comp.lang.ada objects {} and empty array []; New in v.57 [rev. 799]: There were few downloads of this from - OpenSSL bindings were extended; the AdaCore site, so they've not produced - UnZip: fixed bad decoding case for the - The procedure Next_Unbiased was a 2020 edition. This is my attempt at that added to the package Shrink (LZW) format, on some data missing edition! compressed only by PKZIP up to v.1.10, Generic_Random_Sequence. release date 1990-03-15. At https://sourceforge.net/projects/ Ahven 2.8 - Zip.Create: added gnuada/files/GNAT_GPL%20Mac%20 OS%20X/2020-arm-eabi-darwin-bin/ Zip_Entry_Stream_Type for doing From: Tero Koskinen output streaming into Zip archives. Simple Components v4.51 - Zip.Compress: Preselection method Subject: ANN: Ahven 2.8 detects Audacity files (.aup, .au) and From: Dmitry A. Kazakov Date: Sun, 18 Oct 2020 21:47:38 +0300 compresses them better. Newsgroups: comp.lang.ada Zip-Ada is a pure Ada library for dealing Subject: ANN: Simple Components for Ada Ahven version 2.8 is now available from with the Zip compressed archive file v4.51 https://www.ahven-framework.com/ format. It supplies: Date: Sun, 18 Oct 2020 08:43:41 +0200 Newsgroups: comp.lang.ada Direct links to tar.gz and zip packages: - compression with the following sub- The current version provides * https://www.ahven-framework.com/ formats ("methods"): Store, Reduce, releases/ahven-2.8.tar.gz Shrink (LZW), Deflate and LZMA implementations of smart pointers, directed graphs, sets, maps, B-trees, * https://www.ahven- - decompression for the following sub- stacks, tables, string editing, unbounded framework.com/releases/ahven-2.8.zip formats ("methods"): Store, Reduce, arrays, expression analyzers, lock-free Shrink (LZW), Implode, Deflate, data structures, synchronization primitives Ahven is a simple unit test library (or a Deflate64, BZip2 and LZMA (events, race condition free pulse events, framework) for Ada programming - encryption and decryption (portable Zip arrays of events, reentrant mutexes, language. It is loosely modelled after 2.0 encryption scheme) deadlock-free arrays of mutexes), pseudo- JUnit and some ideas are taken from AUnit. Ahven is distributed - unconditional portability - within limits random non-repeating numbers, symmetric encoding and decoding, IEEE under permissive ISC license and should of compiler's provided integer types and work with any Ada 95, 2005, or 2012 target architecture capacity 754 representations support, streams, multiple connections server/client compiler. - input archive to decompress can be any designing tools and protocols Version 2.8 is a minor maintenance kind of indexed data stream implementations. release. The changes are: - output archive to build can be any kind http://www.dmitry-kazakov.de/ada/ * Source code repository of Ahven is now of indexed data stream components.htm hosted at - input data to compress can be any kind Changes to the previous version: Sourcehut: of data stream https://hg.sr.ht/~tkoskine/ahven - output data to extract can be any kind of - Memory leak fixed in the package Generic_Unbounded_Ptr_Array; * Improvements to Janus/Ada build data stream scripts - Bug fix in data selector initialization (in - cross format compatibility with the * Improvements to GNAT build scripts most various tools and file formats the package based on the Zip format: 7-zip, Info- GNAT.Sockets.Connection_State_Mach * Minor documentation updates Zip's Zip, WinZip, PKZip, Java's JARs, ine);

Ada User Journal Volume 41, Number 4, December 2020 198 Ada-related Tools

- Zanyblue 1.4.0 http://www.dmitry-kazakov.de/ada/ HAC v.0.076 (zanyblue.sourceforge.net), strings_edit.htm From: [email protected] - PragmARC mid-2020 This implementation which is only to Subject: Ann: HAC v.0.076 (pragmada.x10hosting.com/pragmarc. demonstrate the possible usages of Date: Sat, 24 Oct 2020 00:38:57 -0700 htm), UXString has many limitations as for Newsgroups: comp.lang.ada - GNOGA 1.6-beta (www.gnoga.com), instance there is no memory deallocation. Only a few API are implemented. HAC (HAC Ada Compiler) is a small, - SparForte 2.3.1 (sparforte.com), quick, open-source Ada compiler, - Alire 0.6.1 (alire.ada.dev), NEW A test program is also provided with some covering a subset of the Ada language. features working. and as side libraries: You find below the changes since the last See readme for full details. post about HAC in this forum. - Template Parser 20.2, - gtksourceview 3.24.4, https://github.com/Blady-Com/ Links to the project and contact (tracing UXStrings/blob/master/readme.md ;-) ) addresses are available from the blog - GNUTLS 3.6.14, From: Vadim Godunko posts cited below. - GMP 6.1.2, 0.071 Discrete type range is stored in type - make 4.2.1, Date: Fri, 27 Nov 2020 00:38:56 -0800 definition; "subtype T1 is T2;" - Python 2.7.17. There are few more options to forget 0.072 Subtype_Indication (e.g. "for B in about encodings and related issues: XNAdaLib binaries have been post on Boolean loop", "array (States) of Prob") Source Forge: New AdaCore's VSS https://gautiersblog.blogspot.com/2020/ https://github.com/AdaCore/VSS https://sourceforge.net/projects/gnuada/ 06/hac-v0072-subtype-indication.html files/GNAT_GPL%20Mac%20OS%20X/ Old Matreshka's League 0.073 The VM can be aborted via the 2020-catalina http://forge.ada-ru.org/matreshka Feedback procedure Report preferably all comments to From: Luke A. Guest 0.074 Types: Time and Duration MacAda.org mailing list: Date: Fri, 27 Nov 2020 11:05:08 +0000 0.075 Added Ada.Calendar-like functions http://macada.org/macada/Contacts.html > There are few more options to forget about encodings and related issues: https://gautiersblog.blogspot.com/2020/ See list archive: 10/hac-v0075-time-functions-goodies- https://hermes.gwu.edu/archives/ My very basic utf-8 string - for.html gnat-osx.html https://github.com/Lucretia/uca 0.076 Added Ada.Directories-like From: Simon Wright subprograms Ada-12 Version of PragmARC https://gautiersblog.blogspot.com/2020/ Date: Sun, 25 Oct 2020 09:39:41 +0000 10/hac-v0076-adadirectories-like.html Great stuff, just a couple of comments - From: PragmAda Software Engineering XNAdaLib 2020 Binaries for > - Python 2.7.17. Subject: [Ann] Ada-12 Version of the macOS Catalina Not maintained since 1 Jan. There are PragmAda Reusable Components excellent downloads of 3 (currently 3.9) Date: Sun, 1 Nov 2020 19:20:42 +0100 From: Blady at python.org. Newsgroups: comp.lang.ada Subject: [ANN] XNAdaLib 2020 binaries for Now that there are 2 (count 'em!) Ada-12 macOS Catalina including GTKAda and > Report preferably all comments to compilers*, an Ada-12 version of the more. MacAda.org mailing list: PragmARCs is available at Date: Sun, 25 Oct 2020 10:11:49 +0100 > http://macada.org/macada/ https://github.com/jrcarter/PragmARC Newsgroups: comp.lang.ada Contacts.html In addition to making use of Ada-12 This is XNAdaLib 2020 built on macOS Gives a (Korean?) 404. features, this version has a restructured 10.15 Catalina for Native Quartz with package hierarchy and is released under GNAT Community 2020 including: You can subscribe at https://hermes.gwu.edu/cgi-bin/ the 3-clause BSD license. - GTKAda 20.2 wa?A0=GNAT-OSX (www.adacore.com/gtkada) with GTK+ These have only been compiled with the 3.24.20 (www.gtk.org) complete, GNAT compiler. Feedback from those RFC UXStrings Package. with access to the other compiler would - Glade 3.22.1 (glade.gnome.org), be welcome. From: Blady - GnatColl 20.2 Subject: RFC UXStrings package. *Defined as a compiler that implements (github.com/AdaCore/gnatcoll), Date: Wed, 11 Nov 2020 21:18:17 +0100 the entire Ada-12 core language. - Florist mid-2020a (github.com/Blady- Newsgroups: comp.lang.ada Com/florist), UXStrings is now a standalone library SweetAda 0.1g - AdaCurses 6.2 (invisible-island.net/ available on Github. ncurses/ncurses-Ada95.html), From: Gabriele Galeotti https://github.com/Blady-Com/UXStrings - Gate3 0.5c Subject: SweetAda 0.1g released (sourceforge.net/projects/lorenz), Comments on specifications are welcome. Date: Sun, 15 Nov 2020 13:16:55 -0800 - Components 4.50 (www.dmitry- A first implementation POC is provided. Newsgroups: comp.lang.ada kazakov.de/ada/components.htm), UTF-8 encoding is chosen for internal I've just released SweetAda 0.1g. - AICWL 3.24 (www.dmitry- representation. The Strings_Edit library is kazakov.de/ada/aicwl.htm), used for UTF-8 encoding management.

Volume 41, Number 4, December 2020 Ada User Journal Ada-related Products 199

This is a maintenance release, and From: Keith Thompson https://r3fowwcolhrzycn2yzlzzw- introduces new toolchains based on on.drv.tw/AdaStudio Binutils 2.35, GCC 10.2.0 and GDB 10.1. Date: Mon, 16 Nov 2020 12:51:39 -0800 web page or Google drive Along with new tools, the basic support I suggest that an announcement like this libraries, e.g., GMP, MPFR, MPC, and all should include, at or near the top of the https://drive.google.com/folderview? auxiliary libraries were used at the highest article, a brief description of what id=0B2QuZLoe- stable version during the builds. SweetAda is. yiPbmNQRl83M1dTRVE&usp=sharing (google drive. It can be mounted as virtual Sorry for a significant delay in releasing, From the web site: drive or directory or viewed with Web but it is very time-consuming to keep Browser) everything in-sync, especially when SweetAda is a lightweight development toolchains change. Neither I had the time framework whose purpose is the The full list of released classes is in "Qt6 to complete the manual, I'll try to do that implementation of Ada-based software classes to Qt6Ada packages relation in the near future. systems. table.docx" SweetAda itself gets few changes: [...] The latest hacker attacks will force many companies to reconsider technologies - due to a deeper Ada code analysis, the AdaStudio-2021 Release based on scripting languages such as new compiler front-end showed possible 01/01/2021 Free Edition Python, Ruby, Perl, JavaScript and others, superfluous aspects; they are removed in which it is much easier to replace code and warnings made silent From: Leonid Dulman than in translated modules. Therefore, - slightly better menu scripts interest in a language such as Ada should greatly increase. - echo_log() and echo_log_error() Subject: Announce : AdaStudio-2021 functions in Bash scripts are now release 01/01/2021 free edition If you have any problems or questions, let renamed as log_print() and Date: Wed, 30 Dec 2020 00:51:09 -0800 me know. log_print_error() Newsgroups: comp.lang.ada - minor changes and typos here and there I'm pleased to announce AdaStudio-2021. Ada-related Products Of course, LibGCC and RTS packages In the new AdaStudio release it was are synchronized with new toolchains, so added Qt6Ada support for new Adalog's "Back to Quality" download them as well. framework Qt-6.0.0. Program I am working on Insight too, hopefully I added some packages from Qt-5.15.0 packages will be available ASAP, but it is open source (qtcharts qtconnectivity From: J-P. Rosen still at 20200417 timestamp. Please note qtgraphicaleffects qtimageformats Subject: [Ann] Adalog's "Back to Quality" that if you install Insight, it will overwrite qttexttospeech qtlocation qtlottie program the standard GDB executable, and you're qtmultimedia qtsensors qtserialbus Date: Sat, 24 Oct 2020 09:03:33 +0200 stuck at 9.1. GPRbuild remains at qtserialport qtwebchannel) Newsgroups: comp.lang.ada 20200417 timestamp as well. Qt6ada version 6.0.0 open source and Adalog annonces the "Back to quality" I discovered a mismatch in QEMU for qt6base.dll, qt6ext.dll (win64), program. Linux 20200817 targeted for ARM, AVR, libqt6base.so, libqt6txt.so(x86-64) built Thanks to our experience and advanced AArch64, x86 and M68k CPUs, where with Visual Studio 2019 tools, we offer technical assistance to executables end up being objects for an x64bin Windows, gcc x86-64 in Linux. relieve your technical dept by fixing non- OS X platform, because of bad naming. Package tested with GNAT gpl 2020 Ada conformities to your coding standard that This is now corrected. Sorry for that, compiler in Windows 64bit, Linux x86-64 you never have time to fix by yourself. please re-download the following Debian 10.0 packages: For more details, see: I built Qt6 binaries for win64 and x86-64 https://adalog.fr/en/btq_program.html qemu-aarch64-20200817L.tar.xz and include them into AdaStudio-2021 or write to [email protected] (qt6ada directory) qemu-arm-20200817L.tar.xz State Preserving Fault qemu-avr-20200817L.tar.xz Known problems: Tolerance for Ada qemu-i386-20200817L.tar.xz 1) for quick3d and quickcontrols2 plugins I have got unresolved entry points Applications qemu-m68k-20200817L.tar.xz ml_registr_types_QtQuick3D(), so some From: Thomas Wetmore examples do not work properly. Furthermore, QEMU for Windows packages lack libffi-6.dll. This is now 2) in Linux multimedia plugins do not Subject: State Preserving Fault Tolerance corrected. Please re-download built properly and services do not work for Ada Applications (qtavada works fine) Date: Wed, 9 Dec 2020 13:37:51 -0800 qemu--20200817W.zip (or Newsgroups: comp.lang.ada place a libffi-6.dll library taken from a 3) webengine does not work and it is not random MinGW64 package, along the added to qt6ada Our small startup has developed a new QEMU executable). Qt 6 is a new long time project and I hope software fault tolerant (FT) architecture, implemented as an SDK and library, that Find everything at to solve these problems in the next release. we are currently adapting for use with https://www.sweetada.org. Ada and SPARK. It will enable By the way, the connection to SweetAda Qt6Ada is built under а GNU GPLv3 developers to create true state preserving, website is now completely secure. Many license: https://www.gnu.org/licenses/ fault tolerant Ada applications by either thanks to the Certbot team. lgpl-3.0.html. developing new or modifying existing code. The architecture provides additional Qt6Ada and VTKAda for Windows, levels of availability and security by Linux () is available from providing resilience against both

Ada User Journal Volume 41, Number 4, December 2020 200 Ada and Operating Systems

hardware failures and software anomalies > Some other Ada-aware IDE for Mac? I guess Eclipse has an Ada plug-in as well. I think AdaCore supports this but (attacks). The port will enable Ada users Emacs[2], with ada-mode[3]]. to create FT Ada applications that can be I'm not sure if the Mac version is well- adapted for most COTS h/w - s/w [1] https://sourceforge.net/projects/ supported. gnuada/files/GNAT_GPL%20Mac%20 platforms. Such applications can even be None of the above except Xcode is a run on heterogeneous, geographically OS%20X/2020-catalina/GNATStudio- 20.2-a.dmg/download native Mac app so you'll have to deal with distributed configurations - using bare a certain amount of cross-platform- metal, virtual machines, or containers. [2] https://emacsformacosx.com turdism. I would happily pay hundreds of Note that this new application-based FT [3] https://www.nongnu.org/ada-mode/ $US for a native Mac Ada IDE but that software technology was created by our ada-mode.html will never happen. The previously- veteran computer design engineers who mentioned Xcode hack was close enough, From: Simon Wright though. have developed multiple generations of fault tolerant systems currently in world- Date: Thu, 15 Oct 2020 10:35:39 +0100 There are lots of text editors that aren't too wide use. The Ada implementation of the bad. I have used Textmate with its Ada technology is being created by a veteran > How to develop Ada programs on a plug-in (bundle) which I've modified for Ada expert who has been developing with Mac today (Catalina)? my own purposes for many years. Not an Ada since its inception. [...] IDE but it does have the capability to link We are looking for users with whom we from parsed error reports back to your can collaborate to 1) provide needs input, > Some other Ada-aware IDE for Mac? code. Textmate was a leader in this area 2) assist with QC & real-world use case Just announced: and its bundle architecture has been used testing, and/or 3) create prototypes and/or by several other editors. https://github.com/thindil/vim-ada/ proofs of concept. Please let me know if Sorry if this is all a little sketchy. you are interested in learning more and releases/tag/v10.0 we will be glad to share additional https://github.com/thindil/Ada-Bundle Now for something OT. If you are doing information. technical work in Ada and want to store From: Jerry or examine or plot results, I have made Date: Thu, 15 Oct 2020 16:41:40 -0700 Igor Pro (wavemetrics.com) work with Ada and Operating > How to develop Ada programs on a Ada. This is a fantastic arrangement. It's Mac today (Catalina)? almost as nimble as working in a Systems notebook (think Jupyter or Jupyter Lab) Some of the following is kind of vague but you get the awesomeness of Igor Pro Developing on a Mac but I hope it is useful. Many listers will to plot, post-process, and document. From: Marius Amado-Alves know much more. From: Blady One time a long time ago someone (on Date: Fri, 16 Oct 2020 22:21:30 +0200 Subject: Developing on a Mac this list?) made Xcode work with Ada. It > There also used to be Carbon bindings Date: Wed, 14 Oct 2020 09:39:58 -0700 was fantastic. Even a debugger IIRC. But Newsgroups: comp.lang.ada to Ada, possibly made by the same apparently Apple likes to change the person. I searched but could not find it. How to underpinnings and after some time Xcode develop Ada programs on a Mac today ceased to work with Ada. (There also is or If I remember well, the Carbon bindings (Catalina)? GNAT CE 2020 for Mac has was a FPC Pascal way with Xcode that were provided by James E. Hopper from a no GPS anymore. Must one use Xcode? was even more capable but I haven't Pascal to Ada translation with p2ada of How to make Xcode Ada-aware and checked into that for a long time.) Apple Carbon API in Pascal. Though Carbon may still work, Apple wasn't integrate it with GNAT? Some other Ada- There also used to be Carbon bindings to aware IDE for Mac? maintaining the Pascal API, but only the Ada, possibly made by the same person. C API. From: Simon Wright (The words "Blady" and "Pascal" come to mind for this person.) They were on the Thus Ada Carbon Bindings weren't used Date: Wed, 14 Oct 2020 20:02:59 +0100 macada.org web site which doesn't seem anymore as far as I know. I provided to do much these days, as well as being some Xcode support to Ada but after, as > How to develop Ada programs on a linked from AdaPower. Of course the you said, Xcode was no more Mac today (Catalina)? GNAT CE 2020 Carbon API has been long-deprecated but customizable. for Mac has no GPS anymore. I'm sure it is still used. (How does You'll find here some historical material: If you want GPS the best bet is probably Microsoft keep Word et al working on to use the GPS from GNAT CE 2019 with Macs?) https://blady.pagesperso-orange.fr/ the new compiler. Have CE 2020 bin first It's not a full IDE in some opinions but alpha.html on your PATH, then explicitly call up Visual Studio Code runs on Macs, even gps: I just used /opt/gnat-ce-2019/bin/gps. my now-ancient 2008 PowerBook and Ada on QNX macOS 10.11.6. There is an Ada plug-in There is a port of GNAT Studio to From: DrPi <[email protected]> but make sure you get the right one. I Catalina[1], but ISTR it's not all working Subject: Ada on QNX think this plug-in might be supported by 100%? Date: Thu, 10 Dec 2020 08:50:53 +0100 AdaCore. And there's something about an Newsgroups: comp.lang.ada > Must one use Xcode? How to make Ada Language Server. I don't really Xcode Ada-aware and integrate it with understand all of this. I've tried to get this Anyone has cross-compiled Ada for QNX GNAT? running but the instructions are minimal SDP 6.6.0 (ARM target)? so it is taking more effort than it should. Last time I heard, Xcode is proprietary From: Quentin Ochem (Why are installation instructions so and closed, and no one has ever reported frequently written assuming that you extending it for Ada. But of course I Date: Thu, 10 Dec 2020 08:03:48 -0800 haven't been looking. already know how to install stuff?) Hi Nicolas, IntelliJ IDEA CE also has an Ada plug-in.

Volume 41, Number 4, December 2020 Ada User Journal Ada and Other Languages 201

FWIW, there's an AdaCore port that has Stream_IO is a lot more flexible that Of course, the alternative is for me to been done specifically targeting Sequential_IO and Direct_IO. (Some translate the Python modules into Ada QNX/ARM. If you want to discuss, feel implementations implement those older which is something I've done in the past; free to drop me an e-mail Ada 83 packages in terms of Stream_IO.) generally, in my opinion, yielding much ([email protected]). better and more readable code. Again, From: DrPi <[email protected]> thanks for your very helpful comments Date: Fri, 11 Dec 2020 10:49:57 +0100 Ada and Other which, hopefully, have focused my mind on the way ahead. Yes, I know. I've been in contact with Languages someone from Adacore about 2 years ago. Regarding your comment that "Python is But the port is for QNX SDP 7.0.0 and Importing Python Library a huge mess" and my own opinion of later only. into Ada Python; I am mortified that Python seems to have become the standard language for It seems that there is provision for a QNX From: Roger Mc teaching computer programming and, compilation in FSF GNAT. Not sure of particularly, that it seems to be the choice that and not tried to go this way yet. Subject: Import Python library into an Ada of leading university computer science package? courses. It seems that the old well- Read/Write Access to UNIX Date: Thu, 3 Dec 2020 23:36:13 -0800 established rules of quality computer Character Devices Newsgroups: comp.lang.ada program design have been completely abandoned by these institutions. Is it possible to import a Python library, From: [email protected] From: Niklas Holsti Subject: Read/write access to Unix such as graphviz, into an Ada package? So far I have only been able to find character devices Date: Fri, 4 Dec 2020 15:22:46 +0200 Date: Sun, 20 Dec 2020 20:59:28 -0800 information on exporting Ada to Python. Newsgroups: comp.lang.ada From: Dmitry A. Kazakov > Is it possible to import a Python library, such as graphviz, into an Ada package? Lately I have been working with Unix Date: Fri, 4 Dec 2020 11:23:21 +0100 (really Linux, FreeBSD, and OpenBSD) If you mean the Graphviz tool-set, character devices (these happen to be I am not sure what you mean. Python is https://en.wikipedia.org/wiki/Graphviz, USB raw HID devices, but the problem is not a compiled language, so formally that seems to be written in C and to be more general than that). The way these speaking a Python library is not a library open source. You should be able to call work is that each hardware device has a and you cannot import it in the sense of Graphviz functions from Ada in the same character device node file in /dev/, like linking it to your application and calling way as one calls any C code from Ada. /dev/hidraw1. You open the file for both subprograms from it using certain calling The Python module you refer to is read and write access. Then you can send conventions. probably just a binding from Python to a command to the device by writing a the C code in Graphviz. If you rather meant whether you could binary blob and get a response by If you want to use Graphviz just to draw subsequently reading a binary blob. For execute a Python script from Ada while passing parameters to it and taking results automatically laid-out graphs, there is what I am doing, it is important not to another way, that I have used: make the block on reads forever if there is no from, yes you can. If that script were a part of some Python module, yes you can Ada program write out the graph response forthcoming, so I need at least definition as a text file in the "dot" read timeouts. load it and once loaded call (interpret) functions from the module. language, and then invoke the "dot" So far, I have been binding the C library program from Graphviz to lay out and functions open(), close(), read(), write(), P.S. Before you proceed, Python is a huge draw the graph into some graphical and poll() with pragma Import. That mess and interfacing it is a pain in the ... format. However, it may be troublesome works, but I have wondered if there is So you should consider if Graphviz is to make this method work interactively -- some way of accomplishing the same worth the effort. If you find a GTK or Qt I was satisfied with non-interactive post- thing more portably. The packages library that is doing approximately the processing of the "dot" file generated by GNAT.Sockets and same, that would be a wiser choice, IMO. my Ada program. GNAT.Serial_Communicatons can be From: Roger Mc From: [email protected] viewed as special case solutions, but I Date: Fri, 4 Dec 2020 05:41:08 -0800 would like a general solution. Date: Fri, 4 Dec 2020 03:37:53 -0800 As a side note, there is a cool utility called What I would really like is Many thanks for your prompt response DePlo ( https://sites.google.com/site/ Ada.Sequential_IO with InOut_File and a and comments Dmitry; they are well depplot/ , sources here : timeout mechanism, perhaps like the appreciated with some of the contents https://launchpad.net/deplo ) that creates a select() wrapper in GNAT.Sockets. somewhat expected. dependency graph of Ada units from the So far I haven't found anything in the I think that I misused the term " Python .ali files that GNAT produces when Ada. or GNAT. that supports InOut_File library"; I think "Python module" is what building a project. semantics (other than Direct_IO) let alone I should have used. This graph is in Graphviz's DOT format. timeouts. Does anybody have any suggestions? In this , in Python, is a module a And indeed, graphviz is not specific to script? I'll investigate this. Python. The sources are in C, and the From: Randy Brukardt [...] Web site mentions bindings to: guile, perl, python, ruby, C#, tcl . Date: Mon, 21 Dec 2020 19:23:08 -0600 The project that I am embarking on is to From: Simon Wright I would use Stream_IO for this, but you'd use Ada for an on-line course in machine need help from your implementer to get learning that uses Python as its teaching Date: Fri, 04 Dec 2020 13:55:15 +0000 timeouts/nonblocking I/O. If they have platform. The importing that I was them, they'd be some sort of Form contemplating concerns special machine > Regarding your comment that "Python parameter (that's what the typically learning Python modules used in the is a huge mess" and my own opinion of ignored Form parameter is for). course. Python; [...]

Ada User Journal Volume 41, Number 4, December 2020 202 Ada Practice

I'd certainly agree that interfacing to 3. Py.ELV_MAX_Cube is an Yes. Python from Ada is a huge mess implementation of a Python module in Ada. I.e. calling Ada from Python. If the program is using ceiling-priority- (specifically, unsupported hand based protection, the priority of the management of garbage collection, as you 4. MAX_Control_Page contains a task calling object must be less or equal to the have to do if invoking Python objects). that periodically runs a Python script. priority of the called object. From: Björn Lundin I.e. calling Python from Ada. > Or is that limited to protected entries only? Date: Fri, 4 Dec 2020 19:32:58 +0100 Ada Practice > If you want to use Graphviz just to draw An entry call is potentially blocking and automatically laid-out graphs [...] therefore not allowed in a protected Logging and Protected operation. And if you really just want to draw graphs Actions - and can use another tool - gnuplot can > Another issue is having two different be controlled by spawning it and sending From: Dmitry A. Kazakov calls: Trace and protected Trace. If one commands on stdin via pipes. is used instead of another, you have a Subject: Re: is there a version of unix ticking bomb in the production code. From: Per Sandberg written in Ada I assume that is a "feature" of the Date: Thu, 1 Oct 2020 11:28:10 +0200 Date: Fri, 4 Dec 2020 22:12:11 +0100 referenced Debug package, not of the Newsgroups: comp.lang.ada basic method it uses to implement a > Is it possible to import a Python library, [...] BTW, I still do not know how to logging facility. such as graphviz, into an Ada package? design an Ada-conform tracing/logging I haven't looked at the Debug package, gnatcoll.python + a lot of binding work facility such that you could trace/log from but I would have suggested a logging anywhere, protected action included, and facility that consists of: From: Roger Mc without knowing statically which protected object is involved. 1. A FIFO queue of log entries Date: Fri, 4 Dec 2020 13:19:10 -0800 implemented in a protected object of From: J-P. Rosen > gnatcoll.python + a lot of binding work highest priority. The object has a Date: Thu, 1 Oct 2020 11:59:58 +0200 procedure "Write_Log_Entry". I have been trying to figure out how to > BTW, I still do not know how to design 2. A task that empties the FIFO queue use gnatcoll.python. Unfortunately it an Ada-conform tracing/logging facility into a log file. The task calls an entry of doesn't seem to provide any supporting such that you could trace/log from the FIFO protected object to get a log documentation. anywhere [...] entry from the queue, but executes the From: Dmitry A. Kazakov Did you have a look at package Debug? file-writing operations in task context, not in a protected operation. Date: Sat, 5 Dec 2020 00:17:12 +0100 (https://www.adalog.fr/en/components From: J-P. Rosen #Debug) > Unfortunately it doesn't seem to provide Date: Thu, 1 Oct 2020 13:48:26 +0200 any supporting documentation. It features, among others, a trace routine > I remember that there was a GNAT which is guaranteed to not be potentially pragma to catch it, but it was a run-time What about this: blocking. https://docs.adacore.com/ check gnatcoll-docs/scripting.html From: Dmitry A. Kazakov Well, just use AdaControl with the rule: I have a rudimentary Python bindings Date: Thu, 1 Oct 2020 12:21:46 +0200 check Potentially_Blocking_Operations; independent of GNATColl, which I use to run Python scripts from Ada. They were > It features, among others, a trace routine ;-) designed to load Python dynamically, I which is guaranteed to not be From: Dmitry A. Kazakov did not want to make the application potentially blocking. dependent on Python installed. If you It calls a protected operation on a Date: Thu, 1 Oct 2020 14:51:54 +0200 want, you can use them as a template. different protected object, yes, this is non- > If the program is using ceiling-priority- There is no documentation, but the code blocking, and I considered the same, but using them. But as I said, better not... (:-)) based protection, the priority of the is this legal? Maybe I am wrong, but I calling object must be less or equal to From: Dmitry A. Kazakov have an impression that walking away to the priority of the called object. another object is not OK. Or is that Date: Sat, 5 Dec 2020 10:38:10 +0100 limited to protected entries only? My mental picture was protected procedure calls executed concurrently on > I would really appreciate seeing your Another issue is having two different different cores of a multi-core processor. "rudimentary Python bindings ". calls: Trace and protected Trace. If one is Would that sort of implementation be used instead of another, you have a legal? Download sources of this: ticking bomb in the production code. I http://www.dmitry-kazakov.de/ada/ remember that there was a GNAT pragma If so, then let there be protected procedure max_home_automation.htm to catch it, but it was a run-time check, so P1 of the object O1 and P2 of O2. If P1 it just replaced one type of explosive with and P2 call to P3 of O3 that would be a The project is large. Only these packages another. problem. Ergo either wandering or are related to Python: From: Niklas Holsti concurrent protected protected calls must 1. Py is the bindings be illegal. 2. Py.Load_Python_Library is an OS- Date: Thu, 1 Oct 2020 14:38:27 +0300 > 1. A FIFO queue of log entries dependent part for loading Python > It calls a protected operation on a implemented in a protected object of dynamically from a DLL (Linux or different protected object, yes, this is highest priority. The object has a Windows) non-blocking [...], but is this legal? procedure "Write_Log_Entry".

Volume 41, Number 4, December 2020 Ada User Journal Ada Practice 203

Yes, that was what I thought and what [...] Now let's continue the example. What 1) mutual exclusion, which is not Debug.adb does. However Debug.adb happens when the calling paths are: "blocking" allocates the body of the FIFO element in O1.P1 --> O3.P3 --> O2.Q 2) for entries: queuing, which is the pool. I would rather use my "blocking" implementation of indefinite FIFO which O2.P2 --> O3.P3 --> O2.Q does not use pools. I don't want Let Q1.P1 blocks Q2.P2 on an attempt to Once you realize this, it should make this allocators/deallocators inside protected enter O3.P3: whole thread clearer.... stuff. O1.P1 --> O3.P3 From: Dmitry A. Kazakov > 2. A task that empties the LIFO queue O2.P2 --> blocked into a log file. Date: Fri, 2 Oct 2020 08:56:38 +0200 Then O3.P3 calls O2.Q: A simpler approach is to flush the queue > mutual exclusion is not blocking. by the first call to an unprotected variant O1.P1 --> O3.P3 --> O2.Q "Blocking" (as in "potentially blocking of Trace. I believe Debug.adb does just | operation") means "being put on a this. O2.P2 --> blocked V queue", i.e. when the waiting time is potentially unbounded. From: J-P. Rosen This will either re-enter O2 or deadlock. Date: Thu, 1 Oct 2020 16:18:58 +0200 From: Randy Brukardt It would be a poor definition, because deadlock is not bounded as well. If > My mental picture was protected Date: Thu, 1 Oct 2020 17:10:10 -0500 jumping from one protected object to procedure calls executed concurrently another is legal, we can construct a on different cores of a multi-core [...] deadlock out of mutual exclusion. We processor. Would that sort of also have a situation when multiple tasks implementation be legal? A task has to wait to get access to a PO. executing protected procedures are This is *not* blocking, it is not allowed to No. Protected objects guarantee that only awaiting their turn to enter a procedure of do anything else during such a period. some object. They will continue (if not one task at a time can be inside (ignoring (This is why protected operations are functions). Multi-cores don't come into deadlocked) in some order, which is supposed to be fast!). It's canonically obviously a queue. play. implemented with a spin-lock, but in > I don't want allocators/deallocators some cases one can use lock-free From: J-P. Rosen inside protected stuff. algorithms instead. Date: Fri, 2 Oct 2020 09:42:02 +0200 As surprising as it may seem, For a single core, one can use ceiling > It would be a poor definition, because allocators/deallocators are NOT locking instead (and have no waiting), but deadlock is not bounded as well. If potentially blocking operations. But I that model seems almost irrelevant on jumping from one protected object to understand your concerns... modern machines. another is legal, we can construct a deadlock out of mutual exclusion. > A simpler approach is to flush the queue From: Randy Brukardt by the first call to an unprotected But this would necessarily involve an variant of Trace. I believe Debug.adb Date: Thu, 1 Oct 2020 17:13:14 -0500 "external call to the same protected does just this. object", which is defined as a potentially > [...] you have a problem when two blocking operation. Note that AdaControl Yes. Moreover, there is a Finalize of a independently running protected is quite powerful at detecting that controlled object to make sure that no procedures of *different* objects call a situation (by following the call graph). trace is lost if the program terminates procedure of a third object. You must without calling any (unprotected) Trace. serialize these calls, and that is > We also have a situation when multiple effectively blocking. tasks executing protected procedures From: Niklas Holsti are awaiting their turn to enter a Not really: blocking implies task procedure of some object. They will Date: Thu, 1 Oct 2020 18:38:12 +0300 scheduling (and possible preemption and continue (if not deadlocked) in some priority inversion), whereas no scheduling order, which is obviously a queue. > My mental picture was protected happens on a protected call. There's just a procedure calls executed concurrently possible wait. It's a subtle difference, No, it can be implemented with a spin on different cores of a multi-core admittedly, but it makes a world of lock. It is bounded by the number of processor. Would that sort of difference to analysis. waiting tasks x service time. You don't implementation be legal? From: J-P. Rosen have to wait for some unpredictable If the protected procedures belong to Date: Fri, 2 Oct 2020 07:36:07 +0200 barrier. different protected objects, yes it is legal. From: Randy Brukardt But not if they belong to the same object, To continue on Randy's response: mutual as J-P noted. exclusion is not blocking. "Blocking" (as Date: Fri, 2 Oct 2020 22:14:49 -0500 in "potentially blocking operation") Note that the ordinary form of the ceiling- means "being put on a queue", i.e. when > But this would necessarily involve an priority-locking method does not work for the waiting time is potentially unbounded. "external call to the same protected multi-cores, because a task executing at The waiting time due to mutual exclusion object", which is defined as a the ceiling priority of a protected object is bounded by the execution time of the potentially blocking operation. does not prevent the parallel execution of protected operation, and then can be other tasks (on other cores) at the same or included in the execution time of the Note that such an operation doesn't really lower priority. waiting task. (In reality, it can be slightly block, it is a deadlocking operation; Ada more complicated, but the idea is that it is lumped it into "potentially blocking" in [...] bounded). order to save some definitional overhead. From: Dmitry A. Kazakov (A mistake, in my view, it should simply [...] have been defined to raise Program_Error Date: Thu, 1 Oct 2020 19:37:01 +0200 or maybe Tasking_Error.) "Potentially In summary, the model of PO is two blocking", in normal use, means levels: something else.

Ada User Journal Volume 41, Number 4, December 2020 204 Ada Practice

From: Randy Brukardt I mean this: Legal programs can run into all sorts of protected body O is problems, starting with use-before- Date: Thu, 1 Oct 2020 17:21:01 -0500 procedure P1 is elaboration. > O2.P2 --> O3.P3 --> O2.Q begin > So my initial disinclination to jump ... from one protected object to another is This latter path is always going to end P1; reasonable advice. deadlock, since the second call to O2 is procedure P2 is necessarily an external call (you're inside begin Quite conservative advice, though. of O3, not O2). An external call has to get P1; -- OK the lock for the protected object, and since > Or at least the order in which protected O.P1; -- Deadlock or Program_Error objects are navigated must be the same. the lock is already in use, that will never end P2; proceed. end O; I would say that it is advisable to arrange the POs (or PO types) in a layered [If O3 was nested in O2, then the second From: Niklas Holsti call to O2 could be internal. But in that architecture and make inter-PO calls only from a higher-layer PO to a lower-layer case, the first path would be impossible as Date: Sat, 3 Oct 2020 10:44:59 +0300 O1 could not see O3 to call it.] PO. > I mean this: Remember that the decision as to whether GDNative Thick Binding a call is internal or external is purely > Design syntactic: if a protected object is given > protected body O is explicitly in the call, one needs to trigger From: Michael Hardeman the mutual exclusion mechanisms again. > procedure P1 is The only time one doesn't need to do that > begin Subject: GDNative thick binding design is when the call does not include the Date: Thu, 15 Oct 2020 14:08:19 -0700 object (that is, directly from the body of > ... Newsgroups: comp.lang.ada an operation). > end P1; I'm working on a binding to the Godot From: Dmitry A. Kazakov game engine for Ada. > procedure P2 is Date: Fri, 2 Oct 2020 08:55:56 +0200 Project link here: https://github.com/ > begin MichaelAllenHardeman/gdnative_ada > This latter path is always going to deadlock, since the second call to O2 is > P1; -- OK Once the game engine has loaded your necessarily an external call > O.P1; -- Deadlock or dynamic library it will call the function Program_Error *_nativescript_init (where * is the Is that implementation or requirement? symbol_prefix defined in the library The lock can be task-re-entrant. That is an internal call, so no deadlock resource config file). This function is > Remember that the decision as to nor error. responsible for registering objects, object whether a call is internal or external is See RM 9.5(4.e), which is this exact case. methods, and allocating any memory purely syntactic: if a protected object is needed. From: Dmitry A. Kazakov given explicitly in the call, one needs to What I want to discuss here is that I'm a trigger the mutual exclusion Date: Sat, 3 Oct 2020 10:16:15 +0200 bit at a loss as to how to design a thick mechanisms again. binding wrapper around this object Even when the object in the call is > That is an internal call, so no deadlock registration pattern. So let me describe the statically known to be the same? nor error. pattern. From: Randy Brukardt I.e. it is *not* based on the syntax of the I have a very simple example translated call. from C using the thin binding here: Date: Fri, 2 Oct 2020 22:09:19 -0500 Anyway the rather disappointing result is https://github.com/MichaelAllenHardema that protected procedures may deadlock n/gdnative_ada/blob/master/examples/gdn > Is that implementation or requirement? ative_c_example/src/simple.adb#L44 The lock can be task-re-entrant. (or Program_Error) in a legal program. So my initial disinclination to jump from The objects must have a name, but may or Language requirement. An external call may not override the constructor/ requires a separate mutual exclusion. If one protected object to another is reasonable advice. Or at least the order in destructor life cycle functions (which you Detect_Blocking is on, then pass in during registration) Program_Error will be raised. Otherwise, which protected objects are navigated any pestilence might happen. must be the same. There are > Even when the object in the call is From: Niklas Holsti https://docs.godotengine.org/en/stable/ statically known to be the same? classes/class_object.html#class-object Date: Sat, 3 Oct 2020 13:44:47 +0300 Yes. An external call *always* gets the There is kind of a hierarchy at play as lock again. I believe that was made the > I.e. it is *not* based on the syntax of the well: rule to make it obvious as to what will call. the Node type extends Object happen based on the form of call. At least not on /that/ syntactical From: Dmitry A. Kazakov difference. https://docs.godotengine.org/en/stable/ classes/class_node.html#node > Anyway the rather disappointing result Date: Sat, 3 Oct 2020 08:42:03 +0200 is that protected procedures may and has addition life cycle events like > Yes. An external call *always* gets the deadlock (or Program_Error) in a legal _process (callback on each frame) lock again. I believe that was made the program. https://docs.godotengine.org/en/stable/ rule to make it obvious as to what will classes/class_node.html# happen based on the form of call. class-node-method-process

Volume 41, Number 4, December 2020 Ada User Journal Ada Practice 205

Now I don't even know where to start I'm pretty familiar with most of the basic what all the types that extend that object defining something nice in Ada that stuff I can do in Ada. I'm not asking for tagged type are, and what all the null would match this pattern and would hide general advice on making a thick binding, methods they've chosen to override are. all the nastiness from the C binding. I I'm asking for help with one specific data Kind of like the Java Class() style kind of want the tagged record hierarchy structure/pattern. introspection. structure, with overriding functions, but it should only register methods with godot What is the best way to make Ada I'm sure there must be some way of doing you've overridden. How would I know types/functions that wrap a particular it better tho, with generics? I'm just not what methods have been overridden? I thing: creative enough to see the solution atm. feel like I need some kind of generic or I just pushed a work in progress branch From: Luke A. Guest helper functions? where you can see what I'm struggling Date: Fri, 16 Oct 2020 19:31:56 +0100 I'm hoping some more experienced people with: might have some suggestions? https://github.com/ > But I need some way of knowing here: From: Luke A. Guest MichaelAllenHardeman/gdnative_ada/ https://github.com/MichaelAllenHarde blob/feature/adventure_game/examples/ man/gdnative_ada/blob/feature/adventu Date: Fri, 16 Oct 2020 07:38:05 +0100 adventure_game/src/engine_hooks.adb re_game/examples/adventure_game/src #L29 /engine_hooks.adb#L28 > I'm working on a binding to the Godot game engine for Ada. https://github.com/ That's what the generic constructor would MichaelAllenHardeman/gdnative_ada/ allow. Ok, so what you have now is a gcc blob/feature/adventure_game/examples/ > what all the types that extend that object generated binding, which isn't the nicest adventure_game/src/example_object.adb to work with. tagged type are, and what all the null #L90 methods they've chosen to override are. What you really need to do is to start by Is it possible to create a type (tagged Kind of like the Java Class() style wrapping up the thin inside a thick record maybe) whose dispatching introspection. binding such that the plug-ins only use the methods automatically register in some > thick binding and that any of the calls way? such as simple_constructor are wrapped, > I'm sure there must be some way of i.e. From: Luke A. Guest doing it better tho, with generics? I'm Godot.Make(Instance : Date: Fri, 16 Oct 2020 19:09:13 +0100 just not creative enough to see the Godot.Root_Class; parameters...) -> calls solution atm. simple_constructor(Instance.Internal_Poi > Is it possible to create a type (tagged record maybe) who's dispatching You can't know what the null methods nter, parameters). Use overloads for this are. Why do you even need to know? kind of stuff. methods automatically register in some way? I'm probably not understanding this, tbf. The way I bind to C is like this: If you mean call Register(Context); on From: AdaMagica 1) If it's a simple function that takes no construction of the object, then have you parameters and returns nothing, then looked at the factory stuff? Date: Sat, 17 Oct 2020 03:09:04 -0700 bind directly. http://www.ada-auth.org/standards/ > package GDNative.Thick.Objects is 2) If it's a simple return type, use an 12rm/html/RM-3-9.html#I2118 expression function to bind. > type Object is abstract tagged private; From: Michael Hardeman 3) Anything else gets a thick binding. > 4) Types are mapped onto the C ones, so I Date: Fri, 16 Oct 2020 11:28:30 -0700 > -- create abstract or null subprograms lift out the definition from the thin for each subprogram here: binding and put it in the root package of not when the object is constructed. I was the thick. I also rename so there's less wondering if something like the following > -- repetitive stuff like were possible: https://docs.godotengine.org/en/stable/c GODOT_VARIANT_* and I case package GDNative.Thick.Objects is lasses/class_object.html#class-object properly, this will be difficult for type Object is abstract tagged private; situations where identifiers are Ada -- create abstract or null subprograms for > function Name (Self : in Object'class) keywords, so rename to something else -- each subprogram here: return Wide_String is abstract; completely if you have to, just document -- https://docs.godotengine.org/en/stable/ > procedure Initialize (Self : in out the change. -- classes/class_object.html#class-object Object'class) is null; function Name (Self : in Object'class) Essentially you want all the C nastiness return Wide_String is abstract; > -- etc... inside the thick binding. procedure Initialize (Self : in out > Look at SDLAda for some ideas, but this Object'class) is null; was done by hand. Anything generated by -- etc... > private private GCC needs to be hand massaged to be > type Object is abstract tagged null nicer imo. type Object is abstract tagged null record; record; From: Michael Hardeman end; > end; Date: Fri, 16 Oct 2020 09:39:17 -0700 But I need some way of knowing here: I do not know what you are trying to do, https://github.com/ but I see a basic misunderstanding here Thanks for the detailed reply. MichaelAllenHardeman/gdnative_ada/ Unfortunately I think I didn't get my wrt keyword abstract on operations. It has blob/feature/adventure_game/examples/ two fundamentally different purposes: question across correctly. adventure_game/src/engine_hooks.adb #L28 * When used on a primitive operation of a non-tagged type, it makes an inherited

Ada User Journal Volume 41, Number 4, December 2020 206 Ada Practice operation disappear, i.e. this operation https://www.adaic.org/resources/ From: Randy Brukardt does no longer exist, e.g.: add_content/standards/05rat/html/ type T is range -42..42; Rat-2-6.html Date: Thu, 29 Oct 2020 15:45:09 -0500 function "/" (L, R: T'Base) return T'Base From: Michael Hardeman > If that is only Windows you do not need is abstract; any. Simply use Windows GDI API Date: Sun, 25 Oct 2020 20:38:36 -0700 * When used on a primitive operation of a directly. [...] There are Win32Ada thin tagged type, this operation is dispatching https://github.com/ bindings, but it is incomplete and most and must be overridden for derived types; MichaelAllenHardeman/gdnative_ada of the time you do not need it. e.g. I've done an initial pass on the thick For Win32, both Claw type T is abstract tagged private; binding. [...] (www.rrsoftware.com) and GWindows procedure Op(X:T) is abstract; provide thick Ada bindings. Much easier type T1 is new T with private; Still, as is, it's pretty nice to use. It only to use than raw Win32. procedure Op(X:T1); takes just a tiny bit of user code to get an From: DrPi <[email protected]> object registered and running a function Date: Fri, 30 Oct 2020 10:37:13 +0100 Now your on each frame. function Name (Self : in Object'class) > If that is only Windows (are you https://github.com/ serious?), return Wide_String is abstract; MichaelAllenHardeman/gdnative_ada/ is a classwide operation, not a primitive tree/master/examples/adventure_game/src Did I say that? ;) operation, so it cannot be overridden. It is Windows GUI Frameworks I currently do my dev on a Windows not a primitive operation of any type, so it machine but a cross-platform framework just declares that such an operation cannot is welcome. exist - a rather useless declaration. From: DrPi <[email protected]> Subject: Which GUI framework? From: Per Sandberg > In short, Windows GDI is ugly but it is Date: Thu, 29 Oct 2020 19:48:36 +0100 native and task-safe. (GtkAda is Newsgroups: comp.lang.ada Date: Sun, 18 Oct 2020 22:21:38 +0200 neither) I'd like to create a PC (Windows) GUI My usual path is: Windows GDI... I used it a long time ago. program. This program needs to be able to Not my best memory. 1) find bindings in other languages and create many Windows and tabs in one of try to understand their intention. them. A working thread receives data From: Luke A. Guest from a serial line and sends messages to 2) Generate a 1:1 binding to the C API the GUI to print received content. Date: Fri, 30 Oct 2020 09:52:11 +0000 since that will provide a sound ground (this is an 100% automatic process). I know the most common way is to use > know the most common way is to use GtkAda. The problem is I'm an Ada 3) Write the high-level binding trying to GtkAda. The problem is I'm an Ada beginner and I never used Gkt. So, the beginner and I never used Gtk. So, the mimic other language bindings while effort is double. keeping an Ada twist to it, effort is double. Gtk isn't all that pleasant either. With a minor effort I managed to do step I have a quite good knowledge of one and two but step three is the hard one. wxWidgets since I have used wxPython > I have a quite good knowledge of Have a look on https://github.com/ for years. I thought I could use wxAda but wxWidgets since I have used wxPython Ada-bindings-project/godot it seems the project is dead. for years. I thought I could use wxAda From: Luke A. Guest Any other binding to wxWidgets that I'm but it seems the project is dead. not aware of? Yup, I agree that wxWidgets is much Date: Wed, 21 Oct 2020 07:59:00 +0100 From: Dmitry A. Kazakov simpler as it was based on MFC, only >> I'm probably not understanding this, portable. tbf. Date: Thu, 29 Oct 2020 20:23:55 +0100 At this time wxAda is dead on my hdd > > Any other binding to wxWidgets that right now and not going to be resurrected > Can you explain the Generic I'm not aware of? until I get some money coming in. Constructor some more? I need to use it now, but I can't exactly figure it out. I If that is only Windows (are you > Any other binding to wxWidgets that found this example: serious?), you do not need any. Simply I'm not aware of? use Windows GDI API directly. They are https://www.adacore.com/gems/ada- No, both efforts were abandoned as it was callable from Ada more or less out of the gem-19 but I have no idea how they can too much work. I have a start to a box because Windows handles all objects use the 'Input attribute as the generator, but like I said, it's not internally as graphic resources. constructor function. It doesn't match happening right now. the signature requested by the generic There are Win32Ada thin bindings, but it at all. From: Dmitry A. Kazakov is incomplete and most of the time you do > not need it. Date: Fri, 30 Oct 2020 10:54:54 +0100 > I have a simple example I was trying to The Microsoft's way of defining and using > I currently do my dev on a Windows get working: https://ideone.com/f5bpr9 types is so idiotic that no reasonably machine but a cross-platform > Do you think you could help me usable thin Ada bindings are possible. I framework is welcome. understand where I'm going wrong just declare an Ada counterpart new as here? appropriate with parameters of types I Cross-platform would be: want in order to avoid casting types. > 1. GTK (GtkAda) In short, Windows GDI is ugly but it is 2. Qt (not sure about the project name) I've never used it, but this might help native and task-safe. (GtkAda is neither) 3. HTTP (Gnoga)

Volume 41, Number 4, December 2020 Ada User Journal Ada Practice 207

From: Chris M Moore Does an Ada "PubSub" package exist? From: Dmitry A. Kazakov Date: Fri, 30 Oct 2020 11:36:27 +0000 Something like this: Date: Sun, 1 Nov 2020 12:18:20 +0100 https://pypubsub.readthedocs.io/en/v4.0.3/ > Cross-platform would be: > It is some sort of message dispatcher Search on Alire returned no result. (which is not thread safe). It is like a Or Tk via https://github.com/ Global search on the internet is "polluted" GUI event manager but for custom simonjwright/tcladashell events. (or https://github.com/thindil/tashy by many Ada answers. but I've not used that). From: Jeffrey R. Carter You do not need that stuff. Even less if From: Jeffrey R. Carter Date: Sat, 31 Oct 2020 19:23:55 +0100 that is not task safe. In the context of the Date: Fri, 30 Oct 2020 13:31:45 +0100 same task, it is just a call. You need no > Global search on the internet is marshalled arguments because the call is Gnoga "polluted" by many Ada answers. synchronous and it must be synchronous (https://sourceforge.net/projects/gnoga/) is There's Google custom search for Ada because it is the same task. The very term all Ada (not a binding) and platform programming topics at "event" makes no sense if the task that independent. https://thindil.github.io/adasearch/ emits it is the task that consumes it. From: DrPi <[email protected]> and the Ada-specific search from the > This is very useful when using a GUI Date: Sat, 31 Oct 2020 12:20:41 +0100 AdaIC at since it allows to directly send https://www.adaic.org/ada-resources/ messages to windows/dialogs/controls. Gnoga is very interesting when the GUI is ada-on-the-web/ remotely run. From: Dmitry A. Kazakov It is not useful, it is a mess, e.g. in GTK. I think using such a system locally is Anyway, the standard Ada library nonsense (very resource hungry). Date: Sat, 31 Oct 2020 19:38:09 +0100 contains implementation of FIFO queues. From: DrPi <[email protected]> > Another question indirectly concerning If you want it 1-n rather than 1-1 use a Date: Sat, 31 Oct 2020 12:14:46 +0100 GUI programming: Does a Ada blackboard instead of a FIFO. Binding to C++ libraries is a problem. "PubSub" package exist? Dueling Compilers In the Python world, there are many ways Yes. We have a commercial middleware From: Jeffrey R. Carter to achieve this. 100% in Ada. We use that thing in automation and control systems. Subject: Dueling Compilers If I remember well, the author of Naturally, it provides publisher/subscriber Date: Wed, 25 Nov 2020 15:08:40 +0100 wxPython has written its own binding services, distributed or not with controlled Newsgroups: comp.lang.ada system for version 3. Before version 3, he QoS. That is so to say horizontal Consider the package used a "standard" one but with many communication between applications or manual patches. tasks. It also has a vertical communication with Ada.Containers.Bounded_ aspect abstracting hardware/protocols Doubly_Linked_Lists; PySide (Python binding for Qt) authors from application. E.g. you can generic also have written their own binding publish/subscribe to a MQTT topic, or to type E is private; system after using one that was not an EtherCAT object, or to a CANOpen package Preelaborable is fulfilling their needs. dictionary object etc without even package EL is new It's a pity since I like wxWidgets' way of knowing if that’s really the thing, Ada.Containers.Bounded_ working. something else or another application. Doubly_Linked_Lists ( Element_Type => E); From: DrPi <[email protected]> Having said that, for horizontal end Preelaborable; Date: Sat, 31 Oct 2020 17:30:15 +0100 communication inside a single process you do not need that in Ada. Many things Two Ada-12 compilers give different Do you know SWIG (http://swig.org/)? done for other languages are not needed results on this. Compiler G accepts it SWIG manages C++ bindings to many in Ada. without problem. Compiler O rejects it languages... but not Ada. However, SWIG with the error message preelaborable.ads: Ada protected objects and tasks provide Error: line 6 col82 LRM:10.2.1(11.8/2), If tools might be of interest, like the tree much more efficient, safer (typed) and parser outputting . Maybe SWIG can a pragma Preelaborable_Initialization has easier to use way to communicate been applied to the generic formal, the be modified to manage Ada. Just an idea. between tasks. But not my skills. corresponding actual type must have From: DrPi <[email protected]> preelaborable initialization AFAICT from From: Luke A. Guest Date: Sun, 1 Nov 2020 11:36:37 +0100 the ARM, the generic formal Element_Type of Ada.Containers. Date: Sat, 31 Oct 2020 16:35:26 +0000 > Ada protected objects and tasks provide Bounded_Doubly_Linked_Lists does not much more efficient, safer (typed) and > Do you know SWIG (http://swig.org/)? have pragma Preelaborable_Initialization easier to use way to communicate applied to it. However, the type List, I know of it and no thanks. My generator between tasks. which probably has [sub]components of would actually be simpler. What I'm looking for is not inter-task Element_Type, does. Publisher/Subscriber for communication. It is some sort of Which compiler is correct? What is the message dispatcher (which is not thread intent of the ARM? Ada safe). It is like a GUI event manager but for custom events. From: Randy Brukardt From: DrPi <[email protected]> Subject: PubSub A simple description here: Date: Wed, 25 Nov 2020 20:19:34 -0600 Date: Sat, 31 Oct 2020 18:58:03 +0100 https://wiki.wxpython.org/WxLibPubSub I'd say both compilers are wrong, in that Newsgroups: comp.lang.ada This is very useful when using a GUI the RM clearly has a bug here and one of Another question indirectly concerning since it allows to directly send messages the implementers should have complained GUI programming: to windows/dialogs/controls. about it to the ARG long ago. :-)

Ada User Journal Volume 41, Number 4, December 2020 208 Ada Practice

I'd suggest you post this question to Ada- parameters that the compiler could tell ACATS that implementations define the Comment so that it gets on the ARG's were PI, so they compiled OK. Preelaborable_Initialization aspect (if radar. they have some other existing way to do > adding PI to the formal private type this, that's fine by us for Ada 2012), but (I'll call Preelaborable_Initialization "PI" would work, but it would reduce the they can if they want. We will insist that in the following for my sanity. :-) usability of the containers in non- bounded containers have P_I if the preelaborated contexts. Similarly, element type has P_I, and that they can be It's clear from 10.2.1 that a type with removing the PI from the container pragma PI which has components of a instantiated if the element type does not would work, but would reduce the have P_I. generic formal type has to have usability of the containers in components that have a type with PI. It preelaborated contexts. Both seem Advent of Code isn't possible to initialize such pretty bad. components without a function call, so the other possibility does not exist. The I presumed that leaving PI on the From: John Perry Bounded containers are designed such container was an oversight. Subject: Advent of Code that there are components of the element Date: Fri, 27 Nov 2020 19:12:21 -0800 type (more accurately, a component of an > So this will have to be an ARG question Newsgroups: comp.lang.ada -- I can't answer it definitively. array of the element type). In order for Does anyone know about Advent of there to be such a component, the formal OK, I'll research the format of Code, and has anyone ever participated type must have PI. Ergo, anybody for a submissions to Ada-Comment and send it for Ada? It's typically a sequence of bounded container written in Ada is in. programming puzzles posed as an Advent necessarily illegal. This is a problem that calendar: one for each new day. someone should have brought up at the > P.S. If you post this question to Ada- ARG. Comment, do me a favor and post this https://adventofcode.com/2020/about analysis along with it. That will save Since it is not required to write language- me having to reproduce it later. Older examples are here: defined package bodies in Ada, one could https://adventofcode.com/2020/events imagine that both compilers are correct in I would have done that anyway. Thanks the sense that they are using some non- for confirming my suspicion that I had thought of it, but I don't have too Ada language to implement the something is rotten in . much time. Some languages maintain containers. But that is a fiction in the case From: Randy Brukardt their own mini-communities and of the containers (every implementation I leaderboards, and it might be a way to know of is in Ada), and in any case, we Date: Fri, 27 Nov 2020 20:35:57 -0600 raise Ada's profile (or even SPARK'S?). intended the containers to be From: Jeremy Grosser implementable in Ada. If they are not, > I think both compilers are doing - that is a bug. expansion of generics, so a generic is only really compiled when it is Date: Sat, 28 Nov 2020 19:36:48 -0800 I don't know what the fix ought to be: instantiated. I did Advent of Code in Ada last year. I adding PI to the formal private type got distracted by other projects and didn't would work, but it would reduce the That would be an incorrect finish it, but found it to be a very good usability of the containers in non- implementation of generic units in Ada. way to learn with focused problems. My preelaborated contexts. Similarly, One has to enforce the language rules solutions are up on GitHub if you're removing the PI from the container would only knowing the guaranteed properties of curious, but knowing what I know now, work, but would reduce the usability of the formal types (knowing nothing about they're far from optimal and some parts the containers in preelaborated contexts. the actual). There is a later legality are definitely in need of refactoring. Both seem pretty bad. recheck in the specification of an instance, but that would be irrelevant in https://github.com/JeremyGrosser/advent I'd be in favor of removing PI and this case since the generic unit already is Preelaboration in general from the illegal. From: Bojan Petrovic language (it serves no purpose other than to encourage implementers to make > I presumed that leaving PI on the Date: Sun, 29 Nov 2020 15:03:45 +0100 optimizations that they should make container was an oversight. I solved a couple of challenges from the anyway - the other intentions don't work It definitely is intended, if the unit is last year's AoC in both Ada and Rust, just or are better handled with other Preelaborated, we definitely want any to get a feel for the differences between mechanisms), but I doubt that I'd get any private types in it to be PI (lest they be them in a puzzle solving context: support for that. unable to be used in Preelaborated units. https://github.com/ALPHA-60/ So this will have to be an ARG question - From: Jeffrey R. Carter advent-of-code-2019 - I can't answer it definitively. Date: Thu, 17 Dec 2020 21:22:50 +0100 I've been organising a weekly recreational P.S. If you post this question to Ada- For those who are interested, this became coding workshop at my company for the Comment, do me a favor and post this AI12-0409-1, approved 2020-12-09 last couple of years, and we've been analysis along with it. That will save me solving Project Euler and Codility tasks. I having to reproduce it later. From: Randy Brukardt stopped doing it in March because of the From: Jeffrey R. Carter Date: Fri, 18 Dec 2020 20:00:02 -0600 Covid-19 situation, but we'll reboot it Date: Fri, 27 Nov 2020 08:32:41 +0100 online on December 1st, when AoC 2020 > For those who are interested, this starts, though our schedule will remain > Ergo, anybody for a bounded container became AI12-0409-1, approved 2020- the same - one AoC problem per week. written in Ada is necessarily illegal. 12-09 A while ago we did some interview I think both compilers are doing macro- For what it's worth, that approval included question exercises on #Ada Telegram expansion of generics, so a generic is only moving most of AI12-0399-1 to this AI, group, so maybe we can do it again there. really compiled when it is instantiated. and making this AI a Binding Presumably any test code used actual Interpretation so it applies to Ada 2012 as From: John Perry well. We agreed not to require in the Date: Mon, 30 Nov 2020 23:08:29 -0800

Volume 41, Number 4, December 2020 Ada User Journal Ada Practice 209

Well, the first day wasn't too bad. It took > On these small files, can you really tell Advent of Code Thread me an hour, mainly because I'm not as the difference in speed between GNAT familiar with Ada as I'd like. Once I re- and HAC? or (insert other favorite Compilation learned file input & remembered the editor, mine is Emacs) and LEA? For From: Alejandro R. Mosteo declare clause, it was quick. me, everything is instantaneous. I'll follow Jeremy Grosser's example and From GNAT Studio I get a range of 1.5 Subject: Advent of Code Thread post my solutions to GitHub, too. sec (an i5 PC @2.9 GHz) to 9 sec (a Compilation lightweight laptop) for building Date: Fri, 05 Feb 2021 17:59:27 +0100 https://github.com/johnperry-math/ aoc_2020_12.adb (almost a benchmark To: Ada User Journal Readership AoC2020.git for easy puzzles ;-) ). [This is a special message in that I am From: Max Reznik directly writing it to the Ada User Journal Date: Tue, 1 Dec 2020 03:37:06 -0800 On the same source, I run hac -v2 aoc_2020_12.adb: readership. Besides the previous thread on Someone posted on reddit: Advent of Code, there were a number of https://www.reddit.com/r/ada/comments/ Compilation finished in 0.000335500 threads for each day. These threads refer k4fn9w/anyone_else_participating_in_ seconds. to unstated off-groups problems and the advent_of_code/ Part 1: Manhattan distance of the ship to discussion is too informal and disjointed (0,0): 1631 (1631.0) to make a coherent post-hoc read, even From: [email protected] after summarizing. For that reason, I am Date: Wed, 2 Dec 2020 12:51:04 -0800 Part 2: Manhattan distance of the ship to not including these threads as-is in the Thanks John for the reminder about the (0,0): 58606 (58606.0) Digest. For the interested readers, I have Advent of Code. It's lots of fun! compiled all the related threads in the VM interpreter done after 0.008894500 newsgroup at the end of this message. Just before starting with today's puzzle, I seconds. There are nonetheless some interesting had the idea of programming the solution So, for this kind of puzzle, it makes a with HAC (and the LEA editor). The tidbits and snippets discussing Ada difference (correct solution to part 1 was features, libraries and resources that, even quick edition-compilation-run cycle of sent at 00:11:01). HAC is an advantage for this contest. without context, may be useful pointers to However, today, I was not quick enough But agreed, it's quite rare. follow. I am keeping these in the to get points. Perhaps another day? following messages, with the title of the Especially on today's puzzle, I didn't even thread they belong to. —arm] Links to my solutions are at the end of the consider using HAC... following post: Day 2: https://groups.google.com/g/ From: John Perry comp.lang.ada/c/ASTsQiya1yQ/m/ https://gautiersblog.blogspot.com/2020/ Date: Mon, 14 Dec 2020 13:56:02 -0800 12/advent-of-code-2020-with-hac-and- sx27Sb3XAgAJ lea.html What follows is a long way of saying Day 3: https://groups.google.com/g/ From: Max Reznik "Thank you." :-) comp.lang.ada/c/zsZV1RSf01c/m/ Date: Wed, 2 Dec 2020 13:29:43 -0800 I spend about 2 hours on each puzzle, Fl7CTEB2AAAJ I gathered a list of GitHub repositories which probably doesn't speak well of my Day 4: https://groups.google.com/g/ from this topic on a page, if someone programming prowess (I've programmed comp.lang.ada/c/7CmcyU37SkA/m/ wants to see all of them in one place. for decades, so I can't really say it's aI2k3YxfAwAJ because I'm learning Ada). Somehow I https://github.com/reznikmm/ enjoy it enough to come back day after Day 5: https://groups.google.com/g/ ada-howto/tree/advent-2020 day. comp.lang.ada/c/aOF1sirDOiY/m/ GEDagaqpAwAJ I also provided mine Ada solutions as The puzzles themselves are usually easy Jupyter Notebooks. You can read them in (to me), and most of the ones with a non- Day 6: https://groups.google.com/g/ or launch in the browser with trivial solution can probably be solved comp.lang.ada/c/co9hjh6F1Ng/m/ "launch | binder" button. trivially, with one exception. At least the xbdMecnjAwAJ mathematics has gotten a little more Have fun :) sophisticated; I used the Chinese Day 8: https://groups.google.com/g/ From: Stephen Leake Remainder Theorem recently, which I got comp.lang.ada/c/jxx-4c2hPng/m/ a kick out of implementing in Ada as a 3EO7rO30BAAJ Date: Wed, 02 Dec 2020 14:59:18 -0800 one-line function (not including a support Day 10: https://groups.google.com/g/ function to compute a modular inverse). I > Just before starting with today's puzzle, comp.lang.ada/c/Z4mmw_t94Ls/m/ noticed that Maxim used Fermat's Little X2MG3IDfAQAJ I had the idea of programming the Theorem. solution with HAC (and the LEA Day 11: https://groups.google.com/g/ editor). The quick edition-compilation- I sometimes roll my eyes at the puzzles, comp.lang.ada/c/BIBRIl7iirw/m/ run cycle of HAC is an advantage for but the one thing I've really enjoyed so far 1tO_250LAgAJ this contest. is how each new puzzle has nudged me to learn a different Ada feature with each Day 12: https://groups.google.com/g/ On these small files, can you really tell new puzzle. I'd spend a lot less time on it comp.lang.ada/c/lqb0iuLXm5E/m/ the difference in speed between GNAT if I allowed myself to use a computer FVGVnyNlAgAJ and HAC? or (insert other favorite editor, algebra system, but the point is to learn Day 17: https://groups.google.com/g/ mine is Emacs) and LEA? For me, Ada, and the really nice surprise has been everything is instantaneous. comp.lang.ada/c/lqb0iuLXm5E/m/ how people have helped out, some of FVGVnyNlAgAJ From: Gautier Write-Only Address them even commenting directly on GitHub. Day 19: https://groups.google.com/g/ Date: Mon, 14 Dec 2020 09:43:05 -0800 comp.lang.ada/c/lqb0iuLXm5E/m/ FVGVnyNlAgAJ

Ada User Journal Volume 41, Number 4, December 2020 210 Ada Practice

Day 23: https://groups.google.com/g/ > http://www.ada- Yes; GNAT Community 2020 with - comp.lang.ada/c/lqb0iuLXm5E/m/ auth.org/standards/2xrm/html/ gnat2020 and -gnatX supports FVGVnyNlAgAJ RM-A-18-26.html Ada.Numerics.Big_Integer. I updated my solution to use that. Day 25: https://groups.google.com/g/ Or comp.lang.ada/c/zcMzC_q9KmA/m/ Doubly_Linked_Lists.Generic_Sorting: From: Jeffrey R. Carter Aa7iA3q4BAAJ Subject: Advent of Code Day 10 http://www.ada-auth.org/standards/2xrm/ Date: Sat, 12 Dec 2020 23:25:41 +0100 From: John Perry html/RM-A-18-3.html Subject: Advent of Code Day 2 > hmm. I got constraint error when I used Date: Wed, 2 Dec 2020 15:45:25 -0800 From: Randy Brukardt Long_Integer; maybe that's not 64 bits? Newsgroups: comp.lang.ada Using Ada.Big_Numbers.Big_Integers Subject: Advent of Code Day 7 was a good exercise anyway. > ...I should have used Gnatcoll.regexp. Date: Mon, 7 Dec 2020 17:44:44 -0600 That sounds like C thinking. If you need I was wondering if there was a pattern > Entry: Bag_Entry := ( Quantity => 10 ); 64 bits, say so, don't hope that optional matching library I could use, and had > language-defined types will be big wanted to ask that, but forgot. enough. From: Stephen Leake > However, GNAT says this is invalid [...] type S is range -(2 ** 63) + 1 .. 2 ** 63 - 1; type U is mod 2 ** 64; Date: Thu, 03 Dec 2020 03:52:47 -0800 In Ada 2005 and later, write: I used 'Reduce is a new Ada 2020 attribute Entry: Bag_Entry := (Quantity => 10, type U is mod Description => <>); (www.ada-auth.org/standards/2xrm/html/ System.Max_Binary_Modulus; RM-4-5-10.html); it can sum an array. In an aggregate, <> means a default From: Gautier Write-Only Address From: John Perry initialized component. Following the Ada Way TM ;-), one has to explicitly ask for Subject: Advent of Code Day 3 Subject: Advent of Code Day 17 Date: Sat, 5 Dec 2020 07:11:06 -0800 a default initialized component - just leaving it out might have been a mistake Date: Fri, 18 Dec 2020 11:47:59 -0800 > Day 4 task is dull :) or intended -- neither the compiler nor a > Advent of Code hasn't been a > reader can tell. The above is clearly *complete* waste of time. ;-) intended. > https://github.com/reznikmm/ada- Far from that: now the major part of the From: Jeffrey R. Carter test suite for HAC stems from AoC: howto/blob/advent-2020/md/04/04.md Subject: Advent of Code Day 7 Flourishes like this: Date: Tue, 8 Dec 2020 12:25:54 +0100 [Omitted output of 27 successful tests for HAC, 15 of them being Advent of Code return Passport (byr .. pid) = > entries. —arm] (byr .. pid => True); > type Bag_Entry is record illustrate idioms that I really want to Starting Time of Real-time learn, thanks for sharing. > Description: Bag_Description := " "; Clock From: John Perry Subject: Advent of Code day 5 Humans are notoriously bad at counting From: Simon Wright Date: Sat, 5 Dec 2020 09:57:00 -0800 things, and even worse at counting things they can't see, so this kind of literal can be Subject: Ada.Real_Time.Time_First According to the Internet (And Therefore a source of errors, especially during Date: Wed, 09 Dec 2020 12:30:44 +0000 It Is True (TM)) the A380 can seat up 853 modification. (At least with Ada these Newsgroups: comp.lang.ada people. My problem had up to 894 seats, tend to be compiler errors, not run-time I opened an issue[1] on Cortex GNAT with the first 5 missing, so it wasn't that errors.) far beyond the realm of reason. RTS, saying Of course, Ada offers a Better Way. You You’d expect Then again, I don't know if anyone would can write want to fly an A380 configured for 853 Ada.Real_Time.Time_First to be quite a people. Description: Bag_Description := long time before any possible value of (Bag_Description'range => ' '); Ada.Real_Time.Clock; but in fact the From: Stephen Leake system starts with Clock equal to or Time_First. Subject: Advent of Code day 5 Description: Bag_Description := Date: Sun, 06 Dec 2020 08:21:24 -0800 (others => ' '); On the other hand, I had written > and ran it through cut/sort/uniq Last_Flight_Command_Time : and be proof against any changes to Ada.Real_Time.Time Next time, try Bag_Description's bounds. := Ada.Real_Time.Time_First; ada.containers.generic_array_sort; From: Stephen Leake ... Quad_Is_Flying := http://www.ada-auth.org/standards/2xrm/ Subject: Advent of Code Day 10 Ada.Real_Time.To_Duration (Now - html/RM-A-18-26.html Date: Fri, 11 Dec 2020 09:04:27 -0800 Last_Flight_Command_Time) From: Stephen Leake < In_Flight_Time_Threshold; > My answer was able to fit in a Subject: Advent of Code day 5 Long_Long_Integer on my machine. but Now - Last_Flight_Command_Time Date: Sun, 06 Dec 2020 08:27:54 -0800 But, due to a bug, I did play with the is going to be quite small, to start with, so Big_Integers package. It worked well, Quad_Is_Flying is going to be True when > Next time, try and I'd recommend taking a look at it it shouldn't be. ada.containers.generic_array_sort; for upcoming The workaround I used was

Volume 41, Number 4, December 2020 Ada User Journal Ada Practice 211

Quad_Is_Flying := From: Simon Wright You have two problems: your assumption Last_Flight_Command_Time /= about Time_First (or perhaps it's not an Ada.Real_Time.Time_First Date: Wed, 09 Dec 2020 20:07:32 +0000 assumption, if you make your own RTS) and the possible overflow of Duration. and then > I would use Next_Time instead of Ada.Real_Time.To_Duration (Now - Last_Time: To indicate an invalid Last_Flight_Command_Time, I would Last_Flight_Command_Time) Great idea; the name isn't right in my < In_Flight_Time_Threshold; either use a discriminated type wrapping a context, but the method applies very well. Time value that depends on a Valid In other words, I was using Time_First as (It's the time by which the next flight discriminant, as you suggested, or just a flag to indicate that command has to have been given before have a Boolean flag, say Last_Flight_Command_Time was invalid. we decide we're not flying anymore. I Flight_Commands_Given that is initially plead that (a) this logic seems not to be False. I would use the discriminated type What would your standard pattern for this our Earth logic, (b) it's a translation from only if there is more than one such sort of problem be? Especially someone's C, (c) the original code has a variable or object in the program. considering that if I make Time_First a comment expressing doubt) large negative number I'll get the opposite From: Niklas Holsti For the overflow, I suggest changing the problem, e.g. predicting ahead for a very comparison to large interval, possibly even leading to Date: Wed, 9 Dec 2020 16:21:02 +0200 Now < Last_Flight_Command_Time numeric overflows. + To_Time_Span > I opened an issue[1] on Cortex GNAT (In_Flight_Time_Threshold) I'm thinking of a Time type with the RTS, saying concept of validity, possibly built round assuming that type Time (Valid : Boolean := False) is > Last_Flight_Command_Time is valid in record > You’d expect the sense we are discussing. That will case Valid is Ada.Real_Time.Time_First to be quite overflow only when when True => Value : a long time before Last_Flight_Command_Time approaches Ada.Real_Time.Time; Time_Last, and the program is likely to when False => null; > any possible value of fail then anyway. end case; Ada.Real_Time.Clock; but in fact the system From: Simon Wright end record; and addition, etc. with appropriate > starts with Clock equal to Time_First. Date: Wed, 09 Dec 2020 20:16:24 +0000 preconditions. I don't see any reason for expecting [...] This conversation has been very (not so sure about the discriminated Time_First to be far in the past relative to valuable, particularly in the case of other record, might be more trouble than it's program start. In fact, RM D.8(19) says similar tests. I suspect, though, that "are worth) "For example, [the start of Time] can we still flying?" is a question that'll take correspond to the time of system more thinking to resolve! [1] https://github.com/simonjwright/* initialization". cortex-gnat-rts/issues/33 Possible to Recover Default From: Dmitry A. Kazakov Contrariwise, it could be useful to know Value of Scalar Type? that Clock actually starts from Date: Wed, 9 Dec 2020 14:16:10 +0100 Time_First, because I have often needed a "Start_Time" object that records the From: reinert > What would your standard pattern for Clock at the start of the program, and it Subject: Possible to recover default value of this sort of problem be? would be much simpler to use Time_First, scalar type? if Time_First is known to equal the initial Date: Sun, 13 Dec 2020 01:54:40 -0800 I would use Next_Time instead of Clock. Newsgroups: comp.lang.ada Last_Time: Assume the following code: Next_Flight_Command_Time : Time := > Quad_Is_Flying := type A_Type is new Natural range 0..9 with Time_First; > Ada.Real_Time.To_Duration (Now Default_Value => 9; begin - Last_Flight_Command_Time) loop A : A_Type; Now := Clock; > < In_Flight_Time_Threshold; Is it later on here possible to get access to if Now >= Next_Flight_Command_Time If Time_First, as the initial value of the default value (9)? If A was a then Last_Flight_Command_Time, would component of a record, one could get it Fire_All_Rockets; really be in the far past compared to Now, "9" via Next_Flight_Command_Time := that computation risks overflowing the some_record'(others =><>).A Next_Flight_Command_Time + range of Duration, which may be as small In_Flight_Time_Threshold; as one day (86_400 seconds), RM But more directly? [Without declaring a end if; 9.6(27). variable, as is made clear in some omitted end loop; posts. —arm] exception > The workaround I used was [...] I was when Constraint_Error => using Time_First as a flag to indicate From: AdaMagica -- the End of Times! that Last_Flight_Command_Time was Put_Line ("Thank you for your invalid. Date: Mon, 14 Dec 2020 01:01:21 -0800 cooperation!"); I do not really understand the problem. It Fire_Death_Star; Even that can still overflow Duration, if more than one day can pass since the last seems you want to be able to access the Self_Destroy; default value like so: end; flight command. N: Natural := Natural(A_Type'Default_Value); > What would your standard pattern for this sort of problem be? This is not possible. There is no corresponding attribute 'Default_Value.

Ada User Journal Volume 41, Number 4, December 2020 212 Ada Practice

If this presents a real problem, submit it to I would argue that if From: Randy Brukardt Ada comment stating why this is declare important. Bar : Baz; Date: Mon, 14 Dec 2020 19:26:10 -0600 From: Dmitry A. Kazakov begin > procedure Library_Foo (Bar : Baz := Baz'Default_Value) Date: Mon, 14 Dec 2020 10:38:40 +0100 is legal, then it must be logically equivalent to: I would have suggested to write this as: > If this presents a real problem, submit it declare procedure Library_Foo (Bar : Baz := <>) to Ada comment stating why this is Bar : Baz := Baz'Default_Value; important. begin since this is the syntax used in aggregates It could in the cases like this: (and why should aggregates have all the From: Simon Wright fun??). procedure Library_Foo (Bar : Baz := Baz'Default_Value) Date: Mon, 14 Dec 2020 18:24:54 +0000 > Put_Line (String (1..10)'Default_Value); -- print garbage You can declare constants in some places, > [ It was a language design bug to allow but not at the library level. But in any implicitly uninitialized variables in the The above isn't a legal attribute prefix in case, being forced to declare a constant first place. Declarations like above any case (can't slice a type). And you each time you need to get at the default should have been illegal.] don't need to because this is clearly an value? aggregate (which is legal in Ada 2012): There is an argument that you should only The same problem arises with container initialise variables at the point of Put_Line (String'(1..10 => <>)); generics. If you have an array keeping declaration if you know what value they -- print garbage container elements, logically freed should take; so that the compiler can From: Randy Brukardt elements need to be "destroyed" in some detect the use of uninitialised variables. way. The default type value would be that Date: Mon, 14 Dec 2020 19:27:39 -0600 thing as well as a default for If you always initialize variables, even if Null_Element, if used. you don't know what value they should > The compiler knows. take, the compiler can't help you if you I think that all non-limited types one forget to assign the correct value. Not always. Never forget generics. One could declare uninitialized, must have would hope to be able to use this on S'Default_Value equal to the default value Personally I always try hard not to declare generic formal types, as most of them are the compiler would use. And it should an uninitialised variable. going to have default values (at least in produce same warnings uninitialized From: Dmitry A. Kazakov new code). values do: From: J-P. Rosen Put_Line (String (1..10)'Default_Value); Date: Mon, 14 Dec 2020 19:53:23 +0100 Date: Tue, 15 Dec 2020 07:47:32 +0100 -- print garbage > There is an argument that you should > I think Robert Dewar argued that From: AdaMagica only initialise variables at the point of variables must be declared in the declaration if you know what value narrowest possible scope. Date: Mon, 14 Dec 2020 07:56:29 -0800 they should take; so that the compiler can detect the use of uninitialised Not applicable if your variable is used in a > procedure Library_Foo (Bar : Baz := variables. loop: Baz'Default_Value) I think Robert Dewar argued that V : Integer; Suppose type Baz has no default value variables must be declared in the begin aspect. Then a call to Library_Foo narrowest possible scope. Which would loop without parameter would use what? imply that at the beginning of that scope Get (V); you should know the value, because it exit when V =0; A solution could be that the attribute is would be the first use of the variable. -- do something with V illegal if there is no aspect. The compiler end loop; knows. From: Randy Brukardt Clearly, initializing V makes no sense. From: Dmitry A. Kazakov Date: Mon, 14 Dec 2020 19:21:53 -0600 From: Dmitry A. Kazakov Date: Mon, 14 Dec 2020 17:31:29 +0100 > N: Natural := Natural(A_Type'Default_Value); Date: Tue, 15 Dec 2020 08:23:33 +0100 > Suppose type Baz has no default value aspect. Then a call to Library_Foo We considered an attribute like that, but it > Not applicable if your variable is used without parameter would use what? becomes a semantic problem if the type in a loop doesn't have a Default_Value and you are loop The default used by the compiler in this: in a context where you don't know (such declare declare as for a generic formal type). I vaguely V : constant Integer := Get; Bar : Baz; remember some other semantic problem, begin begin but I don't remember the details. These exit when V = 0; things could be worked out, but it seemed -- do something with V with an appropriate warning of course. messy. end; end loop; [ It was a language design bug to allow I've long wanted <> to work as it does in implicitly uninitialized variables in the aggregates generally (if that existed, I'd It is related to another long standing issue first place. Declarations like above should also have a restriction to require all with returning values (multiple values) have been illegal.] objects to be initialized; that would from functions and functions with in out > A solution could be that the attribute is provide an encouragement to initialize as parameters (resolved recently). many objects as possible; right now, the illegal if there is no aspect. The [...] compiler knows. iffy thing (not initializing) is the easiest).

Volume 41, Number 4, December 2020 Ada User Journal Ada Practice 213

From: Dmitry A. Kazakov From: AdaMagica For my knowledge, are there good reasons for these syntaxes? Date: Tue, 15 Dec 2020 08:35:32 +0100 Date: Tue, 15 Dec 2020 10:14:59 -0800 From: Gabriele Galeotti >> Put_Line (String Just a story about my work (long ago): (1..10)'Default_Value); -- print garbage Date: Thu, 17 Dec 2020 15:18:34 -0800 Our coding standard required for every > The above isn't a legal attribute prefix type declaration a default value that 1) This allows you to replace your array in any case (can't slice a type). indicated an uninitialised value: with a function with the same name, which takes the subscript as an argument I mean a subtype. type T is ... and returns a value, without touching your Nd_T : constant T := ...; -- Nd: not defined client code. Think about an expensive > And you don't need to because this is X: T := Nd_T; -- required clearly an aggregate (which is legal in lookup table -vs- a simple function which Ada 2012): The idea was that this Nd value should be computes your data. Do not see this as an thus that it would be likely to produce an ambiguity but rather a nice uniformity of > Put_Line (String'(1..10 => <>)); -- exception when used in an expression. calling something for a value. print garbage Also any change of this value should have 2) Nearly the same, but in another context Yes, I would prefer the box notation too. absolutely no effect on the code. In any and without an argument. "NewStatus" However having a proper name would has case, at some time it was decided that the could be, e.g., a constant, as long as types some advantages too: Nd value for numeric types was 0. The match. effect: It was no longer possible to see subtype S is T range T'Default_Value - whether in a declaration like From: Jeffrey R. Carter 100..T'Default_Value + 100; Date: Fri, 18 Dec 2020 09:26:39 +0100 X: T := Nd_T; From: Randy Brukardt > 1) What about array indexing? denoted a truly undefined value or a Date: Wed, 16 Dec 2020 18:43:56 -0600 concrete and correct initial value. The requirements for the language From: Randy Brukardt included a restricted set of characters for > subtype S is T range T'Default_Value source code that did not include brackets. - 100..T'Default_Value + 100; Date: Wed, 16 Dec 2020 18:53:06 -0600 So that is the primary reason parentheses are used. If box was generally allowed, you could > It was no longer possible to see whether qualify it to get this effect: in a declaration [...] this value denoted a However, both arrays and functions are subtype S is T range T'(<>) - 100 .. T'(<>) truly undefined value or a concrete and often used as maps, and so an after-the- + 100; -- Not Ada, but should be IMHO. :-) correct initial value. fact rationalization is that using the same syntax for both array indexing and and it's shorter, too. Of course, if T Typically, values like this, at least those function calls makes it easy to switch doesn't have a default value, neither of the used in debuggers, use some permutation between the two. above is a good idea. :-) of 16#DEADBEEF# since it is obvious in data dumps, and is a rather unlikely value > 2) In Ada, a function without arguments From: J-P. Rosen is called without any parentheses. Date: Tue, 15 Dec 2020 10:07:02 +0100 to be intended. The next version of Janus/Ada will initialize all > In the code "status := NewStatus;", you > V : constant Integer := Get; "uninitialized" objects to this value unless can't tell if NewStatus is a function or a you tell it not to. (Essentially, a version of variable. Well, you can push anything in a Normalize_Scalars, except that these days function, but it's not always it doesn't make much sense for that not to That's because Newstatus is a terrible clear/readable/simpler... be the default. Optimization can remove name. If you'd used New_Status there > V : Integer := <>; -- Invented syntax most unneeded initializations, and if they would be no confusion. for explicit lack of initialization are actually needed, it's better to have a Seriously: Ada 80 required empty known dubious value than stack garbage.) That would make more sense: make parentheses for a subprogram call with no initialization required, and say so if you Ada Syntax Questions explicit parameters. During the review don't care. process that resulted in Ada 83, these were universally reviled and so were From: DrPi <[email protected]> From: Randy Brukardt eliminated. Subject: Ada syntax questions Date: Wed, 16 Dec 2020 18:48:06 -0600 Date: Thu, 17 Dec 2020 23:39:44 +0100 From: Dmitry A. Kazakov Newsgroups: comp.lang.ada > Clearly, initializing V makes no sense. Date: Fri, 18 Dec 2020 10:18:45 +0100 Ada claims to have a better syntax than Saying that you *meant* to have an other languages. I'm fine with, but... 1. Separation of interface and uninitialized value does make sense, implementation. Being an array or though: 1) What about array indexing ? function is an implementation detail of a V : Integer := <>; In some other languages, arrays are map or a named entity. -- Not Ada, but should be IMHO. indexed using square brackets. In Ada, Another example is pointer dereferencing. parentheses are used for function calls and Whenever something is omitted, one In Ada X.A is the same as P.A. In C you for array indexing. In the code "status := have X.A vs P->A. never knows whether it was on purpose or NewStatus(some_var);", you can't tell if a mistake. You get similar issues when NewStatus is a function or an array. Yet another one. All instances of "else" is omitted (RR's style guide only parameterization in Ada deploy () allows that in very specific 2) In Ada, a function without arguments is parentheses. In C++ it would be <>, [], (), circumstances). It's unfortunate that Ada called without any parentheses. depending on semantically irrelevant doesn't have a positive way to indicate In the code "status := NewStatus;", you context. default initialization, outside of can't tell if NewStatus is a function or a aggregates. 2. Languages that like C use bottom-up variable. matching are forced to distinguish certain

Ada User Journal Volume 41, Number 4, December 2020 214 Ada Practice things prematurely on the syntax level. certain users (us Ada programmers) so it Untrue. Both array and variable access This is also the reason why you cannot is "better" for us, although some aspects have side effects on the registers, on the use the result type to distinguish are subjective for sure. cache, on the process memory paging, in signatures in C++, but you can in Ada. the form of exception propagation etc. Thus in C++ you would have something In addition to what others have said, here Even direct effects on the outside world as disgusting as are some further comments on are possible when using machine memory the examples you gave: load instructions. E.g. on some hardware 123ull reading memory at the specific address while in Ada it is just > 1) What about array indexing? location means physical serial input. 123 There are proposals to allow [] as well as All these effects are either desired parts of (), mainly to increase familiarity for new the implementation or else bugs to be Long time ago anything but strictly Ada users. fixed. If desired, why do you care? bottom-up matching was considered too complicated or impossible. So artificial > 2) In Ada, a function without arguments > Reading the code can't tell you the distinctions like () vs [] were invented and is called without any parentheses. writer's intentions. then promoted into orthodoxy. Parameterless functions are rare, and What intentions? Unless you are talking From: Mart van de Wege properly so. about the intention to deploy a specific Parameterless procedures are much more machine instruction, function or array Date: Fri, 18 Dec 2020 17:55:56 +0100 common. Writing gives you no clue. But even then. PDP-11 FORTRAN IV used subprogram calls to > 1) What about array indexing ? Frobnicate_Widget(); implement basically everything, Why would you care? It is obvious that is longer than elementary arithmetic operations. If the NewStatus will return something based on function is inlined, where is any call? the value of some_var. How it does that, Frobnicate_Widget; Functions can be tabulated into lookup by array dereference or function call and seems to have no advantages over the tables. Arrays can be compressed into should make no difference to the caller; shorter form. functions. they are only interested in the final value From: AdaMagica of status. From: Stephen Leake Or another look at it: array indexing is Date: Fri, 18 Dec 2020 15:09:19 -0800 Date: Sat, 19 Dec 2020 09:01:53 -0800 effectively a function call anyway. It is > 1) What about array indexing? > Calling a function can have side effects. "return value of array_base + index". Accessing an array or a variable can't > 2) In Ada, a function without arguments This is true. have side effects. is called without any parentheses. You seem to be implying this is bad; The declaration of the function is a Again, why would you care how why? contract about pre and post conditions, NewStatus returns a value? Either by albeit in Ada incomplete. In SPARK, the > 2) In Ada, a function without arguments contract is firm. As a user of the function, returning the value of a function or by is called without any parentheses. dereferencing a variable, all you're you have to believe the programmer that interested in is the value assigned to This is true. he follows the contract. If the status. implementation needs a side effect, so be You seem to be implying this is bad; it. From: Björn Lundin why? If on the other hand you are a maintainer Date: Fri, 18 Dec 2020 18:38:27 +0100 > For my knowledge, are there good or are chasing a bug, you have to check reasons for these syntaxes? the requirements first, not the body of the > 2) In Ada, a function without arguments function. This comes later. is called without any parentheses. Yes. See the Ada Rationale: http://ada- auth.org/standards/rationale12.html > Reading the code can't tell you the As others have stated, why do you care? From: DrPi <[email protected]> writer's intentions. I often mock up a function with a Date: Sat, 19 Dec 2020 12:50:40 +0100 The intentions are in the requirements (or constant, add a pragma Thanks all for your answers. in the accompanying comments, you hope compile_time_warning/error ("fix they are up to date and not wrong). If implementation later") and only later > Why would you care? there are none, good luck. write the body of the function. And that is the only code change - I don't need to add Calling a function can have side effects. From: Andreas Zuercher an useless empty pair of () just because it Accessing an array or a variable can't is a function to all the callers have side effects. Date: Sat, 19 Dec 2020 09:13:56 -0800 > For my knowledge, are there good > You seem to be implying this is bad; > Untrue. Both array and variable access reasons for these syntaxes? why? have side effects on the registers, on the cache, on the process memory paging, Yes Reading the code can't tell you the writer's in the form of exception propagation intentions. From: Niklas Holsti etc. From: Dmitry A. Kazakov Dmitry, DrPi here is referring to side- Date: Fri, 18 Dec 2020 21:35:37 +0200 Date: Sat, 19 Dec 2020 13:40:25 +0100 effects as viewed from the functional- > Ada claims to have a better syntax than programming paradigm's perspective. other languages. > Calling a function can have side effects. Some programming languages have a Accessing an array or a variable can't "pure" designator (usually the keyword: I would say the claim is that the Ada have side effects. pure) that assures that this subroutine and syntax was rationally designed to have all invoked subroutines therein are pure certain properties, which are desired by (i.e., have no FP side effects).

Volume 41, Number 4, December 2020 Ada User Journal Ada Practice 215

The side effects of which you speak are at For the clients these are of no interest, copying the Fortran-PL/I-PL/1-Simula- the machine-code level: e.g., even less to deserve a different syntax. PL/P-PL/M/CHILL heritage popular in setting/clearing comparison flag(s), The user must simply obey the contract the 1970s*, which itself mimicked setting/clearing carry flag, setting/clearing whatever it be, ignoring the mathematics' usage of parentheses around overflow/underflow flag(s), evictions implementation as much as possible. each matrix. Because there was no way from L1/L2/L3 cache, (on RISC to represent mathematics' subscripts as the processors) latching an address in Ada's unified syntax is a great help here. I notation for indexing, the next best preparation of a load/store, and so forth. quite often replace arrays and variables punctuation for matrix/vector indexing None of these are externally observable with functions. It would be great if literals was borrowed: parentheses. side effects from FP's perspective above were fully equivalent to parameterless the machine-code level. DrPi's FP goals functions. * as opposed to the ALGOL58's, are valid. From: Andreas Zuercher ALGOL60's, ALGOL68's, BCPL's, C's square brackets, so the big split was > > Reading the code can't tell you the Date: Sat, 19 Dec 2020 10:40:53 -0800 somewhere around 1957 for FORTRAN writer's intentions. (and whichever predecessor languages > No? Then it is not about the contracts. influenced it) and 1958 for ALGOL58 > What intentions? (and whichever predecessor languages As witnessed by your final sentence influenced it), as opposed to APL's ⍳ iota The intentions of the Ada programmer to quoted below and multiple other replies design an overtly FP-pure or either an which uses neither parentheses nor square along this thread, the key tactical brackets to pull out an element since 1966 overtly FP-impure subroutine or an FP- advantage of Ada's usage parentheses for impure subroutine by happenstance. array indexing is to accomplish a From: Dmitry A. Kazakov Subroutine here is preferably a function, switcheroo days, weeks, months, years, or preferably at that a single-parameter decades later: to substitute a function Date: Sat, 19 Dec 2020 20:37:31 +0100 function (for ability to utilize over a invocation later for what was formerly an > [...] the key tactical advantage of Ada's century of mathematical-analysis array index. Cute trick. Advantageous in techniques). Ada is showing its 1970s usage parentheses for array indexing is some situations. But for people like DrPi to accomplish a switcheroo vintage by unfortunately omitting overtly who seek contractual assurance of FP- expressing FP pureness as a fundamental purity of (all?) invoked functions (and Not substitute, but to provide whatever principle (among a few other FP features). overt declaration of impurity of other implementation necessary. In fact Ada is DrPi's FP goals are valid. functions), Ada's 1) implicit switcheroo limited in terms of abstractions. There From: Dmitry A. Kazakov there in unfortunate combination with still exist things which cannot be Ada's 2) lack of flamboyantly advertising implemented by user-defined Date: Sat, 19 Dec 2020 18:49:08 +0100 impurity in the replacement function does subprograms. Ideally there should be in fact violate the purity portion of the none. Whatever syntax sugar, there > The side effects of which you speak are contract that the mere offset-into-array should be always a possibility to back it at the machine-code level implementation had—and indeed by a user-provided primitive operation. •overtly• declared in its specification as a Memory paging is pretty much > But for people like DrPi who seek observable. mere offset-into-array operation-of- unquestionable-purity. contractual assurance of FP-purity of What you are saying is a question of (all?) invoked functions (and overt contracts. The contract must include all It is okay for a 1970s Ada to not foresee declaration of impurity of other effects the user may rely on. The contract this, because FP was not a mainstream functions), programming practice back then. (But, of a function may include observable If they are unsatisfied with the higher effects or have none (to some extent). btw, it is not as okay for there to be a lack of HOLWGn each decade since the 1980s abstraction level of Ada, they can switch If contracts were indeed relevant to the to revisit whether HOLWG1 forgot to lower-level languages where syntax then functions without contracted anything, where n>1, n∈ℤ.) This 1970s implementation details are exposed in side effects must have been called using [] faux pas in letting a silent slip-streamed syntax. The best we can do is to explain instead of (). switcheroo into the core contract- why such exposure is a bad idea. No? Then it is not about the contracts. definition declaration mechanism of Ada [ Conceptually Ada has nothing to do (not comments! btw, tisk tisk) is merely with FP and I sincerely hope it never >>> Reading the code can't tell you the some tarnish that an AdaNG (next- will. ] writer's intentions. generation Ada) would fix: e.g., by mandating that all functions (and > This 1970s faux pas [...] is merely some >> What intentions? procedures?) shall be overtly declared & tarnish that an AdaNG would fix > The intentions of the Ada programmer enforced to be pure or impure, which This would be highly undesired. On the to design an overtly FP-pure or either would then mean that only pure functions contrary impure array implementations an overtly FP-impure subroutine or an could substitute for array indexing is the are all OK to implement various heuristics FP-impure subroutine by happenstance. ()-based switcheroo on which so many and caching schemes on the container replies in this thread hang their hat. And Intentions are constraints expressed by side. In fact, Ada moved in that direction DrPi would enjoy seeing the compile-time already by providing crude user-defined contracts. Everything else is errors emerge when some cavalier implementation details. array indexing. Clearly as hardware programmer over yonder changed an evolves towards parallel architectures Ada programmers are not motivated by array index to an •impure• function with partitioned memory, low-level arrays pureness of a subroutine. These are totally invocation as contract violation. The cute will be less frequently exposed in irrelevant. What is relevant is the strength implicit switcheroo isn't evil, but the lack interfaces. Comparing older and newer of the contract. Functions without side of compile-time detection of impurity in Ada code we can see that trend of moving effects are preferable just because they the switcherooed function is what is evil. away from plain arrays. have weakest preconditions and strongest (While drinking tea as none of my postconditions. Side effects weaken business as the meme goes,) I actually Furthermore, purity of implementation is postconditions. claim that Ada's usage of parentheses for not contract, per definition of. Purity is a array indexing was merely happenstance non-functional requirement.

Ada User Journal Volume 41, Number 4, December 2020 216 Ada Practice

There is only few areas of interest for From: Stephen Leake Moreover, from the standpoint of such: programming paradigm, the whole 1. Compile-time evaluation/initialization Date: Sat, 19 Dec 2020 13:51:35 -0800 procedural decomposition is lower level of static objects and constraints. than OO decomposition done in terms of > Reading the code can't tell you the types and sets of types. 2. Optimization, especially in the cases of writer's intentions. fine grained parallelism. FP sits firmly in the procedural world. That's what comments and design Even ignoring all fundamental flaws of In any case there is no reason to reflect documents are for. FP concept, you will find no interest in FP that in the syntax, whatsoever. From: Andreas Zuercher from my side. From: Andreas Zuercher From: DrPi <[email protected]> Date: Sat, 19 Dec 2020 14:20:52 -0800 Date: Sun, 20 Dec 2020 15:10:47 +0100 Date: Sat, 19 Dec 2020 14:11:59 -0800 > > Reading the code can't tell you the >> Reading the code can't tell you the > If they are unsatisfied with the higher writer's intentions. writer's intentions. abstraction level of Ada, they can > That's what comments and design > That's what comments and design switch to lower-level languages where documents are for. implementation details are exposed in documents are for. syntax. For decades, assembly-language A good IDE with code analysis showing programmers said the same thing about you object declaration/use is very useful. No, Dmitry, that is where you are wrong. structured-programming feature-set as In this regard, Ada is the lower-level, Especially when comments are out of being representable in mere comments & sync with the code. grungier, cruder, uncouther programming design documents. For decades, C language, closer to assembly language or programmers said the same thing about I'm surprised that no modern ALGOL60. Languages that have a pure Ada's and C++'s and now Rust's feature- tool/language allows the programmer to keyword (or equivalent elective sets as being representable in mere embed a "complete" documentation in designator for compile-time purity comments & design documents. source files. I'm not talking about enforcement throughout a call-tree of Arguably, the entire history of comments formatted to suit a specific tool subroutines) are the ones that are high- programming from Fortran (1957) and convention, like Python or Perl - level, cleaner, more-sophisticated, more- ALGOL (1958) forward is to encode the strings. I'm talking about embedding refined programming languages, closer to designer's intentions in source code that is schematics, drawings, bitmaps, the lofty heaven of mathematics. This is vetted by a compiler instead of merely mathematical equations, etc directly in the actually a sad commentary on software letting comments and design documents source code. Or maybe the reverse: engineering as a professed practice that bit-rot as the declarative & imperative embed source code in standard document. we cannot even agree which source code marches onward in the flow Like javascript in SVG files. Why not a programming-language feature-sets are of time during initial greenfield .odt file with code sections? Ok, a specific higher-level versus lower-level, grungier completion (after all the “then a miracle would be better. Of course, the versus cleaner, cruder versus more occurs” on the blackboard sketches editor should be specific. No more a sophisticated, and uncouther versus more become rubber meeting road) and then simple text editor. refined. during maintenance (as the design From: Andreas Zuercher There is no good reason for Ada to lack incrementally changes). all of the mechanisms to support FP From: Dmitry A. Kazakov Date: Sun, 20 Dec 2020 08:53:36 -0800 (other than historical happenstance, then being substantially frozen in a Steelman Date: Sun, 20 Dec 2020 09:47:50 +0100 > Then we disagree on the definition of mindset without any follow-on higher level. Mine is the level of Stainlessman (arguably Ada95's, > No, Dmitry, that is where you are abstraction away from calculus toward Ada2005's, Ada2012's would-be set of wrong. In this regard, Ada is the lower- the problem space entities. level, grungier, cruder, uncouther requirements that they have incrementally Ada's inexpressiveness of imprecision of grown into) then Silverman (arguably programming language, closer to assembly language or ALGOL60. vagueness of misrepresenting design SPARK's would-be set of requirements intent in this regard (of inability to that is an ever-closer-to-finished work-in- Then we disagree on the definition of compile-time enforce purity of progress) then Iridiumman then Goldman higher level. Mine is the level of subroutines) is clearly not abstraction. It then Palladiummand then Platinumman abstraction away from calculus toward the is mere self-imposed blindness, ignoring evermore sophisticated requirements for a problem space entities. the purity-enforcement topic altogether. best-practices programming language to Assembly language and Ada have the live up to as humankind's understanding [...] same inability to overtly express and of programming, system engineering, > So is all of Ada's rich typing/subtypes. enforce a declaration of FP-purity. Other software engineering, and mathematics languages have a pure keyword or advances over time). Ada is simply capable of expressing some categories of nonfunctional equivalent for subroutines (i.e., functions, > Furthermore, purity of implementation requirements of the design (e.g., rich procedures, lambdas, coroutines, is not contract, per definition of. Purity typing) but not other more-modern generators) to overtly express compile- is a non-functional requirement. categories of nonfunctional requirement time-enforced purity of the subroutine not (e.g., a pure keyword). making modifications to any data outside So is all of Ada's rich typing/subtypes. of its parameter data and callstack-based Ada is simply capable of expressing some The abstract datatype (in its original transient data. Clearly when a categories of nonfunctional requirements sense, rather than as abstract type in Ada) programming language (i.e., Ada) and of the design (e.g., rich typing) but not is meant to be a part of abstraction assembly language share the same lack of other more-modern categories of expressing the problem space. Purity of feature, they are the more-primitive. nonfunctional requirement (e.g., a pure whatever implementation has nothing to Clearly when other pure-keyword- keyword). do with the problem space. It is a design equipped programming languages can artifact. facilitate & enforce a higher civilization to capture the finer points of a

Volume 41, Number 4, December 2020 Ada User Journal Ada Practice 217 mathematical description of the problem > Ada 202x has Global aspects eye-rollingly barely tolerable to each of domain via a rule-declaration & compile- specifically for this purpose, and they the others. time enforcement that assembly language are compile-time enforced. lacks, they are higher-order and less As no small achievement, Ada achieves primitive. There is no valid definition of This is very good news. I will need to Scott McNealy's “all the wood behind one “higher-order programming language” investigate those AIs further. I take it arrow” vastly more than, say, C++'s or that permits assembly language's lack of a from your wording that Global aspects are D's everything-and-the-kitchen-sink pure keyword (or equivalent purity- a general mechanism that a codebase pandering to me-too-isms. Scala/JVM, enforcement mechanism) to be a higher- could use to implement e.g. the purity Scala/Native, Scala/OO, and Scala/FP are order language than, say, Scala with a check that FP seeks. If a general constantly in a multi-way tug-of-war of pure keyword. Dmitry, your line of mechanism, it will be interesting to sorts (actually 2 orthogonal tugs-of-wars reasoning here of what constitutes a foresee what other categories of axioms at 2 different ontological levels) that again higher-order language is preposterous! can be enforced/assured beyond purity. isn't “all the wood behind one arrow” that Btw, I botched my example of extant Ada better achieves than Scala (so far). From: Stéphane Rivière programming languages in a prior Date: Tue, 22 Dec 2020 11:05:10 +0100 comment that has a purity check on a call > There's no implementation of Global yet, sadly. Hopefully coming soon. > Ada's inexpressiveness of imprecision tree. D has it currently, but it has been of vagueness of misrepresenting design proposed but not yet incorporated into It will be interesting to see the furthest intent in this regard (of inability to .../... Scala. push-the-limits extent of applicability of Global aspects. Thanks for your message. It makes my > Methinks are you simply looking to day. I'm not fluent as you in english, nor troll Ada rather than any serious intent. From: Keith Thompson in Ada concepts (I just use it with joy), No, absolutely not, at least not in the Date: Sun, 20 Dec 2020 13:59:20 -0800 but let me express my admiration for pejorative [sense] that your wording assertions such as: implies. As a system-engineer •critic• of I've never found any of the arguments in > Assembly language and Ada have the finding the flaws in the system at large, I favor of using parentheses for array same inability to overtly express and am always performing gap analysis on indexing convincing, and I've never liked enforce a declaration of FP-purity. current Ada versus desired state of a the way Ada does it. But of course the universal programming language, using a decision was made in the early 1980s, and Although this thought also plunges me technique not unlike FMEA. At some it can't be changed now. into an abyss of reflection: level you are coincidentally correct: I am negatively disappointed with Ada as At least part of the reason was that Ada > Ada's inexpressiveness of imprecision much as C++ as much as Scala as much needed to be used on systems that didn't of vagueness of misrepresenting design as D as much as Kotlin as much as Swift have '[' and ']' in their character sets. I intent in this regard (of inability to as much as C# as much as OCaml, but in don't know to what extent that necessity compile-time enforce purity of different ways and to different degrees for has been used as an after the fact subroutines) is clearly not abstraction. each language. rationalization. There remains a mystery. For example, I admire so many portions Function calls and array indexing can be substituted for one another in *some* Why does your message remind me of of Ada, especially its declarative rich typing expressivity and its 35-year lead in circumstances, but not in all. But they this scene from another genius, Stanley really are very different things. A Kubrick? accomplishing much of what C++20 will finally get with their oft-pursued concept function call executes user-written code, https://www.youtube.com/watch? and may have side effects; an array v=iAHJCPoWCC8 feature. Conversely, it is sad that few people realize that Ada has had much of indexing expression refers to an object. No need to answer me, I don't have your the new whizbang C++20 concept feature An array indexing expression can appear skills to debate it. Just be assured that this for 35 years. on the LHS of an assignment; a function post is not mocking and more expressing call can't. amazement. It is as if Ada is a mostly superior product whose salesmen don't consummate as If Ada had originally used '[' and ']' for From: Randy Brukardt many sales contracts as they ought. It is array indexing, I doubt that anyone would useful to study in depth precisely why the be complaining that it would have been Date: Mon, 21 Dec 2020 18:58:51 -0600 superior product partially fails to achieve better to use '(' and ')' (other than some Fortran programmers, I suppose). >Ada's inexpressiveness of imprecision of its potential glory. vagueness of misrepresenting design One of the most interesting successes of Why not use parentheses for record intent in this regard (of inability to Ada is that its user community seems to components, Object(Component) rather compile-time enforce purity of have fairly consistently utilized the vast than Object.Component Doesn't the same subroutines) ... majority of the features of the language argument apply? Which Ada? Ada 202x has Global aspects on a regular basis. Despite C++'s > There are proposals to allow [] as well specifically for this purpose, and they are perceived popularity by comparison, each as (), mainly to increase familiarity for compile-time enforced. Methinks are you C++ codebase utilizes 10% of C++, but new Ada users. simply looking to troll Ada rather than worse it is a different 10% of C++ utilized any serious intent. for each different codebase with vast Ick. The only thing more confusing than rivalry between codebases regarding using () for array indexing would be There's no implementation of Global yet, which portions of C++ are God's gift to allowing either () or [] at the sadly. Hopefully coming soon. humankind and which portions of C++ programmer's whim. (Well, not the only From: Andreas Zuercher are uncouth. Hence, C++'s perceived thing; I'm sure I could come up with popularity is more of a mirage than it first something even worse.) Date: Mon, 21 Dec 2020 18:39:45 -0800 appears because there is no one C++ that > Parameterless procedures are much is popular, but rather a hundred subsets of more common. Writing C++, 75 of which are intensely unpopular to each of the others and 24 of which are > Frobnicate_Widget();

Ada User Journal Volume 41, Number 4, December 2020 218 Ada Practice

> is longer than dereferencing, and there would not be >> X : T (Y); anything else (which means getting rid of > Frobnicate_Widget; type conversions, array indexing and > That's not an expression and is not slicing, and anything else I've forgotten resolved (that is, there is no possible > and seems to have no advantages over overloading). the shorter form. about). Compilers are smart enough to generate better code when they know I see no fundamental difference between I wouldn't have expected the designers of something about the function involved "first-class" expressions and type- Ada to be concerned about saving two (including if it is that of a predefined expressions. characters. container). Doing that would allow >> Then what is wrong with indexing? I see your point about procedure calls. A overloading to be more general and to statement consisting of an identifier allow for the complication of variable > Nothing is "wrong" with it, it is just followed by a semicolon can only be a returning functions. redundant. As others have noted here, procedure call (I think), so there's no From: Dmitry A. Kazakov both indexes and function calls ambiguity. My mild dislike for the represent a mapping. What's the point function call syntax is that it needlessly Date: Tue, 22 Dec 2020 09:00:14 +0100 of having two ways to represent a treats the zero-parameter case as special. mapping? In an Ada-like language, > If I was starting today, () would be a there's no syntax nor semantic There could also be some potential function call, and . would be difference. ambiguities, though I'm not aware of any selection/dereferencing, and there actual ambiguous cases in Ada. In some would not be anything else Both are mappings, but unless you make languages, the name of a function not functions first-class citizens there exist followed by parentheses refers to the But you cannot get rid of X(...) syntax, language level differences between a function itself (or its address) and does where X is an object. It is not only function and a container object. not call it. I can easily imagine an indexing, e.g. in declarations: attribute for which Func'Attribute could X : T (Y); > Ada (and most other languages) are full sensibly refer either to the function Func of redundant stuff. Simplify the basics itself or to the value returned by calling it. Then what is wrong with indexing? It and then one has more room for should simply apply to all types [from interesting stuff (static analysis, parallel Again, if Ada 83 had required empty some predefined class]: execution, etc.). parentheses on parameterless procedure X (...) ::= CALL (, X, ...) Yes, but I would rather keep all this stuff and function calls, I'm skeptical that (...) ::= CALL (, ...) anyone would now be arguing that it was in the language making it overridable a bad decision. From: Randy Brukardt primitive operations. From: Randy Brukardt And again, it would be impossible to Date: Tue, 22 Dec 2020 19:23:51 -0600 change it without breaking existing code. Date: Wed, 23 Dec 2020 22:06:03 -0600 From: Dmitry A. Kazakov > Then what is wrong with indexing? > Hmm, where is the operation? A Nothing is "wrong" with it, it is just prefixed view is Date: Mon, 21 Dec 2020 09:08:30 +0100 redundant. As others have noted here, > Function calls and array indexing can both indexes and function calls represent > .(...) a mapping. What's the point of having two be substituted for one another in > Indexing is *some* circumstances, but not it all. ways to represent a mapping? In an Ada- like language, there's no syntax nor > (...) IMO the only circumstances violating this semantic difference. substitutability are language design bugs I neglected to mention that what Ada calls and deficiencies: Ada (and most other languages) are full of objects are also function calls in this redundant stuff. Simplify the basics and proposed generalization. (Much like - Passing array elements in in-out mode then one has more room for interesting enumeration literals are in Ada.) So for - Assigning array elements stuff (static analysis, parallel execution, static semantics (that is, compile-time), etc.). - Multidimensional indices pretty much everything is a function call. From: Dmitry A. Kazakov This gets rid of the anomalies associated - Slices with constants (which don't overload and all these must be substitutable with user- Date: Wed, 23 Dec 2020 09:59:46 +0100 thus hide more than a parameterless defined subprograms. function - which is otherwise the same >> But you cannot get rid of X(...) syntax, thing); combined with variable-returning From: Randy Brukardt where X is an object. functions, everything is overloadable and treated the same in expressions. Almost Date: Mon, 21 Dec 2020 19:04:43 -0600 > That's a prefixed view, of course. No one would want to get rid of that. no special cases (operators still require > Function calls and array indexing can some special casing, but we can make be substituted for one another in Hmm, where is the operation? A prefixed them always visible which would *some* circumstances, but not it all. view is eliminate more issues). This is false in modern languages with .(...) Clearly a compiler for this language (which can't be Ada, unfortunately, way user-defined indexing (Ada and C++ Indexing is included), since what looks like array too incompatible) would special-case indexing can actually be implemented (...) some kinds of built-in functions for things with a function call. like objects and indexing. But that doesn't In particular: need to hair up the semantic model, just Not having variable returning functions is "abc"(1) the implementations. a flaw in Ada, IMHO. These days, I think there are still too many special cases in >> It is not only indexing, e.g. in >> Ada (and most other languages) are Ada. If I was starting today, () would be a declarations: full of redundant stuff. Simplify the function call, and . would be selection/ basics and then one has more room for

Volume 41, Number 4, December 2020 Ada User Journal Ada Practice 219

interesting stuff (static analysis, parallel From: Niklas Holsti From: Randy Brukardt execution, etc.). Date: Mon, 21 Dec 2020 09:44:30 +0200 Date: Mon, 21 Dec 2020 19:19:44 -0600 > Yes, but I would rather keep all this stuff in the language making it [...] > Perhaps RM-A.10.8(8) should be overridable primitive operations. clarified/corrected. It seems that the Get procedure Yeah, you don't plan to formally describe understands ':' as a base indicator, as in For what it's worth, we once tried to do nor implement this language, so you don't that, but couldn't come to an agreement on really care about how complex it gets. :-) "12#44#" works, Value = 52, Last = 6. precisely what to change the wording to. Well, at least not until performance "12#44" fails with Data_Error. As a change is not critical, we didn't make suffers. Ada is reaching the limit of what one. The ACATS has long had tests in can be done without substantial [...] this area that require something subtly incompatibility. If we're going to allow From: Dmitry A. Kazakov different than the wording requires, and it that, we need to start with a cleaner base, didn't make any sense to change them and part of that is getting rid of Date: Mon, 21 Dec 2020 08:57:36 +0100 (since presumably all implementers are redundancies. passing them, rather than strictly [...] following the RM wording). From: Dmitry A. Kazakov Colon: is a replacement character for # In any case, the ":" replacement trips up Date: Thu, 24 Dec 2020 10:37:10 +0100 (see allowable replacements of people from time-to-time, as pretty much characters). So it might think of 29: 116 no one remembers it. I recall we had to > I neglected to mention that what Ada as a malformed base-29 number with change some piece of new syntax because calls objects are also function calls in wrong base and missing closing:. the possibility of a colon in a number this proposed generalization. made it ambiguous. [...] Well, you must stop the recursion somewhere. It is fine to treat access to From: Niklas Holsti On the Future of the objects as calls, e.g. to getter/setter, or to Distributed Systems Annex indexation, or to dereferencing, but you Date: Mon, 21 Dec 2020 10:06:47 +0200 must finish at some point with something I see, an "obsolescent feature" in RM J.2. From: Rod Kay spelled as a call to a subprogram. In the I learn something new every day (I hope). Subject: 2dsa | !2dsa? case of a subprogram call you are already Date: Tue, 22 Dec 2020 12:00:48 -0800 there. With "objects" you need a few hops Ok, so no bug. Newsgroups: comp.lang.ada to get there. From: Jeffrey R. Carter I've heard that the Distributed Systems [...] Date: Mon, 21 Dec 2020 10:40:17 +0100 Annex (DSA) may be dropped from the > I see, an "obsolescent feature" in RM Ada standard soon. Can anyone confirm > Ada is reaching the limit of what can be this? done without substantial J.2. incompatibility. If we're going to allow Yes. I never worked with a system that I've been using the PolyORB that, we need to start with a cleaner required such substitutions, even in 1984 implementation of DSA for some time base, and part of that is getting rid of when it was not an obsolescent feature, and find it very useful. The way in which redundancies. but as we can see, it's important to be it abstracts away socket 'plumbing' details aware of them. makes for very simple/understandable We see that differently. So far new comms. features were added on top which These days they are sometimes used for From: Randy Brukardt naturally leads to the mess we observe. obfuscation. The problem is lack of generalization not inconsistency. If the new Ada cannot From: Randy Brukardt Date: Tue, 22 Dec 2020 19:32:37 -0600 express the old messy, but consistent Ada, > I've heard that the Distributed then this new Ada is not general enough Date: Mon, 21 Dec 2020 19:11:32 -0600 Systems Annex (DSA) may be dropped and it will arrive at the same amount of > Yes. I never worked with a system that from the Ada standard soon. Can mess sooner or later. required such substitutions, even in anyone confirm this? Getting Integers from 1984 when it was not an obsolescent Annex E remains in the proposed Ada feature, but as we can see, it's important 202x standard. Strings to be aware of them. Compiler support, of course, is up to From: John Perry I believe that restriction had to do with vendors. Dunno if anyone is still Subject: Help parsing the language manual certain keypunches. But hardly anyone supporting it. on Get'ing integers from Strings used keypunches even in 1981. (The Date: Sun, 20 Dec 2020 16:11:43 -0800 Unisaur computer that our CS compiler- > I've been using the PolyORB Newsgroups: comp.lang.ada construction class used still had a few implementation of DSA for some time keypunches, but they had mostly and find it very useful. The way in Sorry if the subject is unclear. I recently transitioned to terminals by that time. I which it abstracts away socket tried to use think that was the last class to use the 'plumbing' details makes for very Get(S, Value, Last); Unisaur; they just had installed some simple/understandable comms. VAX 780s for research and they soon got ...in a program where Value was a Natural That was the promise, not sure it ever some for student use as well. My first few really was realized. Since the Annex was and S has the value "29: 116 82 | 119 24". programming classes at UW used the GNAT gave me a Data_Error. weakened enough that third-party support Unisaurs keypunches.) I think that isn't really possible anymore (necessary to I don't understand why. [...] requirement was obsolete by the time Ada allow it to be used with current was completed (it probably wasn't when middleware), it's really a vendor-specific the Ada design was started). thing these days.

Ada User Journal Volume 41, Number 4, December 2020 220 Ada Practice

From: Dmitry A. Kazakov Is it likely that the ARG might address the you want to multiplex RPCs made from aforementioned issues? different tasks rather than interlock them Date: Wed, 23 Dec 2020 09:44:26 +0100 From: Randy Brukardt (which for synchronous RPC would result > Compiler support, of course, is up to in catastrophic performance). vendors. Dunno if anyone is still Date: Mon, 28 Dec 2020 17:41:39 -0600 The current Annex E is very crude to supporting it. >Is it likely that the ARG might address allow efficient, low-latency, real-time It should be moved to the user level. As the aforementioned issues? implementations. specified in the Annex there seems no As of now, it doesn't appear that there P.S. If Ada supported delegation, obvious way to provide a user-defined would be any point. Annex E is an introspection and getter/setter interface, transport for DSA, and there seems no optional annex, and so far as we're aware, then, probably, all remote call/objects way to have different implementations of no compiler vendor has any plans for stuff could be made at the library level. DSA in the same program. increasing support for that annex. So the But for now, compiler magic is needed. [...] ARG could change the annex but it seems From: Randy Brukardt unlikely that any changes would make it > [...] it's really a vendor-specific thing into implementations. (We've been told Date: Thu, 31 Dec 2020 17:43:39 -0600 these days. not to expect even the implementation of bugs fixes included in Ada 202x, even > Why should there be any vendor Yes, I always wished to include DSA support in the first place? Why not to support based on various communication from the vendor that originally requested the bug fixes.) redefine it as a set of abstract tagged protocols I have implemented in Ada, types allowing custom user rather than plain sockets. E.g. I have a From: Dmitry A. Kazakov implementations like storage pools and ready-to-go DSA implementation for streams do? interprocess communication over shared Date: Tue, 29 Dec 2020 15:56:35 +0100 memory, but no idea how to make GNAT Marshalling/unmarshalling surely require >> Is it likely that the ARG might address vendor support, and there has to be a aware of it. Or AQMP and ASN.1 look the aforementioned issues? like a straightforward candidate as a DSA standard interface for the marshalling transport as they have detailed type > As of now, it doesn't appear that there stuff to talk to. That to me was always the description systems to map Ada objects. would be any point. value of Annex E. My understanding is that there is not much interest in doing From: Maxim Reznik Why should there be any vendor support any work at all, even to correct the in the first place? Why not to redefine it mistakes in the existing definitions. Date: Thu, 24 Dec 2020 04:02:24 -0800 as a set of abstract tagged types allowing custom user implementations like storage In any case, Storage_Pools and Streams I forked an older (Garlic) GNAT DSA pools and streams do? are some of the most expensive features implementation and found it quite of Ada to support. That's not a model for hackable. :) The idea of having an IDL, statically "lightweight" support of anything. assigned partitions, linking everything My idea is to implement a together before start is not the way the My advice would be to talk to your WebSocket/WebRTC transport and distributed systems are designed and work vendor if you feel strongly about this sort compile it by GNAT-LLVM to today. CORBA died for a reason. of support. WebAssembly to have distributed Ada applications in a browser. I have a From: Dmitry A. Kazakov Easiest Way to Use Regular working proof of concept demo already :) Date: Tue, 29 Dec 2020 16:51:19 +0100 Expressions? https://github.com/reznikmm/garlic/tree/ web_socket > Would the compiler still need any From: reinert support for this or would it just be a set Subject: Easiest way to use redular From: Dmitry A. Kazakov of interfaces at library level? expressions? Date: Thu, 24 Dec 2020 14:30:54 +0100 Yes, because the idea is to have remote Date: Sun, 27 Dec 2020 00:20:11 -0800 objects and remote calls looking exactly Newsgroups: comp.lang.ada > I forked an older (Garlic) GNAT DSA the same as local objects and local calls. implementation and found it quite I made the following hack to match a hackable. :) So the compiler must translate a call to an string with a regular expression (using a RPC to a call to some user primitive named pipe and grep under linux): My question is how to proceed without operation like System.RPC does. The GLADE/Garlic etc. I have DSA [Omitted example of spawning a process operation would have a controlling and capturing the output. —arm] implemented, e.g. System.RPC. I need parameter "connection" or "remote GNAT to accept it as such. partition". The actual input values of the OK, I assume it somehow breaks the In a more distant perspective I need a original call must be marshaled, e.g. as an philosophy on Ada and work-around of stream attributes. They output stream. The output values and the security/reliability. Could someone are non-portable, so there must be an result will be returned via an input stream therefore show a better and more simple option to replace them for DSA and/or and deserialized from there into the actual way to do this? gnat.expect? provide a non-stream parameter parameters/result or else into a remote From: J-P. Rosen marshaling when the transport is a higher- exception occurrence to re-raise locally if Date: Sun, 27 Dec 2020 09:36:49 +0100 level protocol, e.g. CANopen, EtherCAT, that was the outcome. ASN.1, AMQP etc. For these you must AdaControl uses Gnat.Regpat, and is Here lie a lot of problems. First is non- quite happy with it... map Ada types into the types defined by portability of stream attributes. Second is the protocol. Without this DSA is pretty lack of support for bulky transfers and From: Emmanuel Briot much pointless. multiplexing. It is highly desirable that From: Rod Kay the output stream could be written in Date: Sun, 27 Dec 2020 03:14:47 -0800 Date: Sun, 27 Dec 2020 11:34:10 -0800 chunks as well as reading the input > AdaControl uses Gnat.Regpat, and is stream. E.g. if you pass large objects or if quite happy with it...

Volume 41, Number 4, December 2020 Ada User Journal Obituary 221

GNAT.Regpat is a package I wrote 18 From: Gautier write-only address years ago or so (time flies..), basically Obituary manually translating C code from the Perl Date: Thu, 31 Dec 2020 04:33:30 -0800 implementation of regular expressions. > Tag : String renames Tragic News about Vinzent Nowadays, I think it would be better to Elements.Get_Tag_Name (Child); Hoefler write a small binding to the pcre library (which has quite a simple API, so the > Is it equivalent to the following line ? From: Dirk Craeynest binding should not be too hard). This will > Tag : String := provide much better performance, support Elements.Get_Tag_Name (Child); Subject: Tragic news about Vinzent Hoefler for , and a host of regexp features Date: Wed, 28 Oct 2020 11:09:09 -0000 that are not supported by GNAT.Regpat. Since the temporary object containing the Newsgroups: comp.lang.ada result of the call Never did that while I was working for "Elements.Get_Tag_Name (Child)" is not Dear all, AdaCore because we would have ended accessible anywhere else, the effect is the Many of you may know Vinzent Höfler. up with too many regexp packages (there same. is also GNAT.Regexp, which is very I am sad to pass the most tragic news that efficient but limited in features because it But, perhaps in some implementations, Vinzent died last Wednesday 21 is based on a definite state machine). the "renames" accesses that temporary October... object, which means the memory I think libpcre might even be distributed containing it must not be freed until Tag Below is the message Vinzent's wife with gcc nowadays, although I did not is out of scope. Perhaps it is even Katja Saranen asked me earlier today to double-check so might be wrong. required. Any compiler specialist here? share with the Ada community. This binding would be a nice small From: Jeffrey R. Carter He was active in various forums and project for someone who wants to get Date: Thu, 31 Dec 2020 15:49:04 +0100 newsgroups as Vinzent aka "Jellix" aka started with writing Ada bindings > Tag : String renames "[email protected]" aka From: Maxim Reznik Elements.Get_Tag_Name (Child); "[email protected]" aka "[email protected]". He worked on > Is it equivalent to the following line ? Date: Mon, 28 Dec 2020 05:58:06 -0800 professional as well as open-source Ada > Tag : String := projects, was a member and participated The Matreshka library has rather Elements.Get_Tag_Name (Child); in events of ACM SIGAda, Ada-Europe advanced regexp engine with full Unicode and Ada-, and helped with support No. A function result is a constant, so the several recent Ada DevRooms at 1st version gives you a constant. The FOSDEM events. https://forge.ada-ru.org/matreshka/wiki/ second gives you a variable with the same League/Regexp value. I first met Vinzent what seems an eternity From: Jeffrey R. Carter From: DrPi <[email protected]> ago at the SIGAda 2002 conference in Date: Mon, 28 Dec 2020 22:07:24 +0100 Date: Thu, 31 Dec 2020 16:55:34 +0100 Houston. Our paths crossed many times since, until five years ago he became an You can use PragmARC.Matching. > No. A function result is a constant, so "Ada" colleague at Eurocontrol. Regular_Expression or its instantiation for the 1st version gives you a constant. Character and String, PragmARC. The second gives you a variable with I will miss Vinzent, as a colleague, as a Matching.Character_Regular_Expression the same value. like-minded spirit on various issues, and most of all as an intelligent human being. https://github.com/jrcarter/PragmARC/ Good to know. I will miss our interesting discussions: we tree/Ada-12 What disturbed me was the function call had too few... Renames Usage associated with "renames". Dirk From: Dmitry A. Kazakov [email protected] (for Ada- From: DrPi <[email protected]> Belgium/Ada-Europe/SIGAda/WG9) Subject: renames usage Date: Thu, 31 Dec 2020 19:48:43 +0100 Date: Thu, 31 Dec 2020 12:48:25 +0100 > What disturbed me was the function call Message from Katja Saranen, Wed Oct 28 Newsgroups: comp.lang.ada associated with "renames". 2020: One can read here Renaming a call to a function does not ** https://github.com/AdaCore/svd2ada/ rename it in some functional- blob/master/src/descriptors-field.adb#L83 With the deepest sorrow I have to share programming manner. It renames only the with you a devastating tragedy. this line: result of. Our beloved Vinzent has left this world, Tag : String renames So if you do Elements.Get_Tag_Name (Child); he is not with us anymore. X : Float renames Random (Seed); Is it equivalent to the following line? Vinzent "Jellix" Saranen (Höfler, Y : array (1..10) of Float := (others => X); Fritzsche) Tag: String:= Elements.Get_Tag_Name That would not give you ten pseudo- 09.01.1974 - 21.10.2020 (Child); random numbers. But this will: From: John Perry Z : array (1..10) of Float := (others => Unspeakable loss for so many. A father, Date: Thu, 31 Dec 2020 04:10:21 -0800 Random (Seed)); son, brother, grandfather, husband, friend, colleague and much more. No. Assignment copies the object, and changes to the copy don't affect the The love of my life. My soulmate. My original, while renaming obtains a person. My husband. My safe place. reference to the object. [...] Incredible, wonderful, beautiful, weird, intelligent, talented. So special in so many ways.

Ada User Journal Volume 41, Number 4, December 2020 222 Obituary

We were supposed to grow old together why it is not an end. No goodbyes. Just From: Shark8 and move to wilderness. I was not good memories. Hailing frequencies supposed to outlive you. I was not closed, sir." Date: Wed, 28 Oct 2020 07:24:32 -0700 supposed to face the world without you. I don't know yet how am I even expected to (Star Trek TNG; Tasha Yar) Tragic news indeed. keep going without you on my side. There will be no funeral or grave. He has Sorry to see him go. This is not a farewell. You're not gone. been cremated yesterday and next From: Anh Vo Love is not any less. You're always with summer I will take his ashes to the place Date: Wed, 28 Oct 2020 11:35:56 -0700 me until we meet again. Love you, where he was happiest and where he forever. wanted to go to grow old. For a place to > Tragic news indeed. remember him, you can go to nature starlingc/katja anywhere and you'll always be close. > Sorry to see him go. Memorial(s) will be planned at later time, Rest in peace. Sincere condolences. "Death is that state in which one exists I am not able to now. only in the memory of others, which is

Volume 41, Number 4, December 2020 Ada User Journal