From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=0.5 required=3.0 tests=BAYES_05,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Aleksy Grabowski Newsgroups: comp.lang.ada Subject: Help with designing data structure for novice Ada programmer Date: Sat, 8 Jan 2022 21:41:26 +0100 Organization: A noiseless patient Spider Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sat, 8 Jan 2022 20:41:26 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="ada32d08fc4d17bff0f383df6d203fd1"; logging-data="1664"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19M+muCQOBjCYvKWdKA1WJp" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:96.0) Gecko/20100101 Thunderbird/96.0 Cancel-Lock: sha1:L2kYUz7l8Ni0PtzzkeRkwTQ5O8s= Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:63355 List-Id: Hi all, I'm new here. I'm experienced embedded C developer and I've started 2 years ago an implementation of one of the specifications kind of popular in the payment industry. I also hope to make it open source one day. I've implemented most of it in C, but now I have a problem, because I have to guarantee consistency of a huge configurable data structure, that can be changed by an entity which in theory may not be in my control. And adding all checks quickly became nightmarish and then I've found an Ada language. I already did some experiments, but it doesn't look right, because my experience in Ada is around 1 week. And I want to quickly assess if it is worth doing at all. So my requirements: 1. Important: Syntax to accessing, setting, comparing, allocating values should be as simple as possible, because the body of code is generated from diagrams and it should be understandable by a non programmer, ie payments expert. In C I've wrote some macros for it. 2. Memory management should be unobtrusive to the visual look of diagrams. In C I've used a memory pool, so I just have to do a single de-allocation after each transaction. 3. It should support optional, mandatory and conditional fields. In C modeled as pointers. 4. It should support bit fields that may have different meaning if some flag is set (in C a union of bitfields) 5. Consistency between elements, if a particular flag is set to True then some other fields must have a certain value as well. Probably doable by Dynamic_Predicate. 6. Data elements should be accessible by name `db.processingStatus' or by it's tag value like `db (16#CA#)' and also it should support any additional tag that can be supplied by the card, even if its symbolic name isn't known (in C it's void*). 7. I have to guarantee consistency of a different views of the same value eg. amount represented as BCD array – usual representation or 32 bit unsigned integer when requested by tag 16#81#. 8. It should be possible to modify data elements both symbolically or using binary arrays with encoded data. Either because it is specified this way or I have to set it to the unspecified value. In C I've achieved this by having a union of char[] and a bitfield. 9. And as a bonus it should be serializable to EMV's variant of TLV which isn't the same as you have in ASN.1, because EMV specification was standardized before ASN.1 BER and those committees had little to no cooperation. I'm asking Ada wizards if it is at all doable in Ada? Or maybe some links to opensource project where something similar was already achieved so I can look it up? -- Best Regards, Alex P.S. My code is available on github if someone is interested.