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!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Some kind of repeating in Static_Predicate Date: Tue, 5 Jun 2018 15:37:30 -0500 Organization: JSA Research & Innovation Message-ID: References: <4ece357c-025c-45ff-9f5d-89c89d47e6c0@googlegroups.com> <87efhnoymp.fsf@jacob-sparre.dk> <503aed95-bd48-4eeb-a2a2-0f7bcc8de307@googlegroups.com> <675621d4-7f23-48bd-a7e0-4105b21ddfd7@googlegroups.com> Injection-Date: Tue, 5 Jun 2018 20:37:30 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="5126"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:52949 Date: 2018-06-05T15:37:30-05:00 List-Id: "ytomino" wrote in message news:675621d4-7f23-48bd-a7e0-4105b21ddfd7@googlegroups.com... > On Tuesday, June 5, 2018 at 6:33:48 AM UTC+9, Randy Brukardt wrote: ... >> > Thanks. But I want to separate the table and the subtype... >> >> That seems backwards to me. You are wanting to declare a set subtype, and >> Ada uses the silly static predicate for doing so rather than having a >> proper >> set constraint. Either way, that's a subtype declaration. >> >> So the operative thing here is the subtype. There's no "table" in a set >> description. If you need to check membership in the set, you just do that >> with "in". >> >> Thus: >> >> subtype T is Character >> with Static_Predicate => (T in 'T' | 'a' | 'b' | 'l' | 'e'); >> >> if Param in T then ... >> >> If you really needed a table, I'd construct that from the set. (But I >> can't >> imagine what the use would be, certainly in cases like the "separators" >> definition you showed in another mail.) > > Thanks. I understood it's backwards. > Yes, the table is needless in run-time. I want only compile-time checking >by Static_Predicate in this case. Also, types should be more primary than >constants basically. > However, a subtype declaration can't be separated to another package... Of course a subtype can be declared in another package, I'm not sure why you say that. For subtypes, you can always declare another subtype in your primary package to get visibility: package Params is subtype Separators is Character with Static_Predicate => Separators in '/' | '\'; -- other configuation parameters here. end Params; with Params; package File_Ops is subtype Separators is Params.Separators; -- Other file operations here. end File_Ops; (Using the same exact name isn't a good idea if you are the sort to stick use clauses everywhere,but of course the names don't have to be identical.) Also note that "use type" and "use all type" will give you appropriate visibility on the operators (and primitive operations, in the case of "use all type") regardless of where the type is declared - another reason to prefer "use type" when possible. >The table may be configured before compiling, like the example of directory >separators. Yes, see above. Randy.