Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Looking for feedback: ISO 3166-1 country Country Code Reference in Ada

55 views
Skip to first unread message

A.J.

unread,
Apr 15, 2023, 2:52:10 PM4/15/23
to
I just created a library for accessing ISO 3166-1 records in Ada compatible with Ada.Locales. Before I try to publish it to Alire, I'm hoping to get some feedback if anyone has some. It's possible that feedback will result in the function calls, naming convention, or structure being set up differently, so please let me know what you think.

https://github.com/AJ-Ianozi/iso_3166

I also posted this on the subreddit, so apologies for any redundancy for those viewing both!

Jeffrey R.Carter

unread,
Apr 17, 2023, 5:36:59 AM4/17/23
to
On 2023-04-15 20:52, A.J. wrote:
> I just created a library for accessing ISO 3166-1 records in Ada compatible with Ada.Locales. Before I try to publish it to Alire, I'm hoping to get some feedback if anyone has some. It's possible that feedback will result in the function calls, naming convention, or structure being set up differently, so please let me know what you think.
>
> https://github.com/AJ-Ianozi/iso_3166

Some initial thoughts on what you have:

It seems likely that your clients will use the alpha codes for input and
display. It will be more convenient for that if the alpha codes are subtypes of
String rather than distinct types.

Since you have already enumerated all 250 possible alpha codes, your predicates
could look like

subtype Alpha_Code_2 is String (1 .. 2) with
Dynamic_Predicate => Alpha_Code_2 in "AF" | "AL" | ...;

and similar for the 3-letter codes.

Since you have already enumerated all 250 possible numeric codes, you could use
a restricted range for your numeric (sub)type, with a predicate restricting it
to valid values.

These use the language to do validity checking for you.

Regarding the design of such a pkg, my initial instinct was to use enumeration
types for the alpha codes, but a little investigation shows that some of the
codes are Ada reserved words, so that doesn't work. So I would stick with the
String subtypes and provide functions such that, given one of the values, the
client can obtain the others, as well as the name. Alternatively, one could have
functions to return a record such as you provide. Which is preferable depends on
how such a pkg is typically used.

There are various possible implementations, with different tradeoffs.

--
Jeff Carter
"He nevere yet no vileynye ne sayde
In al his lyf unto no maner wight."
Canterbury Tales
156

0 new messages