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-Thread: 103376,7178c15dc3019a0d X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!208.49.83.146.MISMATCH!uns-out.usenetserver.com!news.usenetserver.com!pc02.usenetserver.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail Newsgroups: comp.lang.ada Subject: Re: How to extend packages References: <8d94d993-4807-4356-b1ab-1f2bb3f96b98@56g2000hsm.googlegroups.com> <484977AB.20002@gmail.com> From: Stephen Leake Date: Sat, 07 Jun 2008 10:21:30 -0400 Message-ID: User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.2 (windows-nt) Cancel-Lock: sha1:kisU33n/iqOdiZ70wE3k0sNMpBg= MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: e24e7484a943ce194287731942 Xref: g2news1.google.com comp.lang.ada:598 Date: 2008-06-07T10:21:30-04:00 List-Id: S�bastien Morand writes: > snoopysalive@googlemail.com a �crit : >> Hi, Ada-folks! >> >> I'd like to extend the GNAT.Regpat a little bit, so that it contains >> additional operations like Split (the same as in Perl or Ruby) or Join >> (dito). >> >> When speaking of "extending" I mean it in the sense of e.g. Java where >> extending a class means that the child class contains all the public >> or protected operations and attributes as the super class. Perhaps you >> know now, what I want to achieve. I want to have an extended "child" >> package of GNAT.Regpat. In the end it should have an own name like >> e.g. "Mine.Regex" and contain all operation etc. of its "super" >> package plus the operations I'll additionally implement. >> >> I've been trying for hours now, so I'm passing this question to you. >> How to extend package? > > Try this: > > with GNAT.Regpat; use GNAT.Regpat; > > package GNAT.Regpat.Extended is > end GNAT.Regpat.Extended; This is probably the best approach. > Then when you use GNAT.Regpat.Extended, GNAT.Regpat is available too. This is not true. To be precise: Suppose GNAT.Regpat declares 'foo', and GNAT.Regpat.Extended declares 'bar'. with GNAT.Regpat.Extended; package A is ... end A; Within A, you can say GNAT.Regpat.Extended.foo, or GNAT.Regpat.bar, but 'foo' and 'bar' by themselves are not visible. with GNAT.Regpat.Extended; package B is use GNAT.Regpat.Extended; ... end B; Within B, you can say GNAT.Regpat.Extended.foo, or GNAT.Regpat.bar. 'foo' is visible by itself, but 'bar' is not. with GNAT.Regpat.Extended; package C is use GNAT.Regpat.Extended; use GNAT.Regpat; ... end C; Within C, 'foo' and 'bar' are both visible. -- -- Stephe