comp.lang.ada
 help / color / mirror / Atom feed
* Looking for feedback: ISO 3166-1 country Country Code Reference in Ada
@ 2023-04-15 18:52 A.J.
  2023-04-17  9:36 ` Jeffrey R.Carter
  0 siblings, 1 reply; 2+ messages in thread
From: A.J. @ 2023-04-15 18:52 UTC (permalink / raw)


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!

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Looking for feedback: ISO 3166-1 country Country Code Reference in Ada
  2023-04-15 18:52 Looking for feedback: ISO 3166-1 country Country Code Reference in Ada A.J.
@ 2023-04-17  9:36 ` Jeffrey R.Carter
  0 siblings, 0 replies; 2+ messages in thread
From: Jeffrey R.Carter @ 2023-04-17  9:36 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-17  9:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-15 18:52 Looking for feedback: ISO 3166-1 country Country Code Reference in Ada A.J.
2023-04-17  9:36 ` Jeffrey R.Carter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox