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.0 required=3.0 tests=BAYES_20,FORGED_GMAIL_RCVD, FREEMAIL_FROM,NICE_REPLY_A autolearn=ham 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: Re: Help with designing data structure for novice Ada programmer Date: Sun, 9 Jan 2022 10:49:35 +0100 Organization: A noiseless patient Spider Message-ID: References: <87sftx1vpd.fsf@nightsong.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 9 Jan 2022 09:49:35 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="7246112190663a2a5aae7c1f00952642"; logging-data="16398"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1907v+fNXr13wqqJLnD+yna" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:96.0) Gecko/20100101 Thunderbird/96.0 Cancel-Lock: sha1:f7OzVFbOuNO7tjYpvyKmudVIXu0= In-Reply-To: <87sftx1vpd.fsf@nightsong.com> Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:63359 List-Id: First of all thanks for an answer. On 1/9/22 03:36, Paul Rubin wrote: > Can you say what specification it is? Yeah sure, it's called nexo. It is an open specification and it is available for free after a registration on nexo-standards.org. It is basically a high level description of an abstract payment terminal. They specify all the data structures and full flow of control. Basically they try to combine all EMV books and all regional payment schemes into a one huge beast, to make a universal terminal. > It sounds like you waht to define a datatype for this structure, with > access and update procedures (OOP is not necessary but it's the same > idea) that make sure all the rules are followed. Is there more to it > than that? Something more. The first thing is update procedures, Right now I have two modules trusted and non-trusted. Trusted part just does whatever it wants to and non-trusted uses geters and setters. But the other thing is that I want to model data as close to the spec as possible, so if it is set to update some enum to a value 16#3F00# I do this. The another part is because they tried to unify the whole payment zoo into single spec there a lot of bizarre things there. I also have some concrete question, how to properly implement optional element? Right now I have something like this: generic type T is private; package TypeUtils is type Optional(exists : Boolean) is record case exists is when True => value : T; when False => null; end case; end record; end TypeUtils; But it looks like it doesn't work, because it depends on the discriminant `exists' but it is set once in .ads file and I can't modify it in runtime. > Ada sounds like a reasonable choice, C sounds terrible, other > possibilities depend on the hardware and software environment. Would > this have to run on a smart card cpu or anything like that? Not really, arm CPU is enough. The one I have is MAX32590. I'm also not really worried about memory consumption. Those embedded platforms have a plenty of RAM nowadays. How large this project can be? I'm already two years into it :)