From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.unit0.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: How to get Ada to ?cross the chasm?? Date: Tue, 8 May 2018 23:53:45 +0300 Organization: Tidorum Ltd Message-ID: References: <1c73f159-eae4-4ae7-a348-03964b007197@googlegroups.com> <87k1su7nag.fsf@nightsong.com> <87po2la2qt.fsf@nightsong.com> <87in8buttb.fsf@jacob-sparre.dk> <87wowqpowu.fsf@nightsong.com> <16406268-83df-4564-8855-9bd0fe9caac0@googlegroups.com> <87o9i2pkcr.fsf@nightsong.com> <87in88m43h.fsf@nightsong.com> <87efiuope8.fsf@nightsong.com> <87lgd1heva.fsf@nightsong.com> <87zi1gz3kl.fsf@nightsong.com> <878t8x7k1j.fsf@nightsong.com> <8736z4k4th.fsf@nightsong.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net xPRSSTao11w+W0Q2xCS6pgiXhnG5DE7iQyAzd5JzpCcIx30qSX Cancel-Lock: sha1:33qsMjx2+r9LCS2g615GlhxmOqo= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: <8736z4k4th.fsf@nightsong.com> Xref: reader02.eternal-september.org comp.lang.ada:52126 Date: 2018-05-08T23:53:45+03:00 List-Id: On 18-05-06 21:38 , Paul Rubin wrote: > Niklas Holsti writes: >> The Ada programs for satellites on which I am currently working often >> meet with such problems, and either work slower (mutual exclusion >> between readers and writers), use more memory (dual physical copies of >> the data structure) and/or pass the problem to the satellite operators >> (commands to mutate the on-board data structure are delayed or failed >> if the data structure is in use by some reader). Better solutions are >> needed. > > I think the natural Ada-flavored solution is use more memory. You're > describing a classic transactional database update which has > traditionally been implemented using shadow pages. Basically you write > the record in two places, then commit the transaction by flipping a > pointer. Yes, something like that is sometimes used. > Because I can't resist, here's a beautiful Haskell implementation of > red-black trees using zippers, with the RB-tree invariants guaranteed by > the type signature: > > https://gist.github.com/2660297 (based on https://redd.it/ti5il) The ideas behind the implementation may be beautiful, but the code is painful to my eyes; for example: insertAt x (BC pb pa py (EC gb ga (R ul ua ur) gc)) = insertAt g gc where p = if pb then B x pa py else B py pa x u = B ul ua ur g = if gb then R p ga u else R u ga p One of the things I really like in Ada, and in the Ada programming style, is the emphasis on readability, and the ability to provide meaningful names for operation parameters, both in the operation declaration _and_ in calls. Quick, what is the meaning of the argument "py" to insertAt? The concepts of functional programming are attractive to me, but the practical problems or long, position-specific argument lists, and the style of using very short identifiers, scare me. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .