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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7936408ed8296efa X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-04-16 04:45:29 PST From: "Martin Dowie" Newsgroups: comp.lang.ada References: <9b9g7c$cp6$1@taliesin.netcom.net.uk> <3ada9cf5$1@pull.gecm.com> <9behk1$ik9$1@taliesin.netcom.net.uk> Subject: Re: User define attributes Date: Mon, 16 Apr 2001 12:37:40 +0100 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 NNTP-Posting-Host: sg2c11210.dsge.edinbr.gmav.gecm.com Message-ID: <3adad7ab$1@pull.gecm.com> X-Trace: 16 Apr 2001 12:29:47 GMT, sg2c11210.dsge.edinbr.gmav.gecm.com Path: supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!news.iac.net!news-out.cwix.com!newsfeed.cwix.com!news.maxwell.syr.edu!colt.net!easynet-quince!easynet-melon!easynet.net!btnet-feed5!btnet!newreader.ukcore.bt.net!pull.gecm.com!sg2c11210.dsge.edinbr.gmav.gecm.com Xref: supernews.google.com comp.lang.ada:6912 Date: 2001-04-16T12:37:40+01:00 List-Id: well, if you mean someting like type My_Type ...; for My_Type'Image use ...; you can't (that's for stream read/write only... I think), but as attributes are defined as functions anyway (check annex L) you can force your generic to require an Image function and even do nifty instantiations like... generic type My_Type is private; with function Image (X : My_Type) return String; package Test is procedure Call (X : My_Type); end Test; with Test; package Tester is new test (Integer, Integer'Image); For composite types you have to "roll your own" Image routine that would probably just call up the scalar 'Image routines in turn or other rolled composite IMage routines. Ayende Rahien wrote in message news:9behk1$ik9$1@taliesin.netcom.net.uk... > Okay, what abuot defining my own? > > "Martin Dowie" wrote in message > news:3ada9cf5$1@pull.gecm.com... > > don't think you can. I believe 'Image is available for all scalar types. > > you could do something like > > > > generic > > type Blah is private; > > function Image (X : Blah) return String; > > package <...>; > > > > > > Ayende Rahien wrote in message > > news:9b9g7c$cp6$1@taliesin.netcom.net.uk... > > > How do I add attributes to a type I create? > > > > > > And how do I require certain attributes to be exist in a type? (I want a > > > generic package to accept only types that has 'Image attribute) > > > > > > Thanks in advance, > > > Ayende Rahien > > > > > > > > > > > >