From: Stephen Leake <Stephe.Leake@nasa.gov>
Subject: Re: How to extend packages
Date: Sat, 07 Jun 2008 10:21:30 -0400
Date: 2008-06-07T10:21:30-04:00 [thread overview]
Message-ID: <uod6d4979.fsf@nasa.gov> (raw)
In-Reply-To: 484977AB.20002@gmail.com
S�bastien Morand <seb.morand@gmail.com> 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
next prev parent reply other threads:[~2008-06-07 14:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-06 17:00 How to extend packages snoopysalive
2008-06-06 17:24 ` witmer
2008-06-06 17:45 ` Sébastien Morand
2008-06-07 14:21 ` Stephen Leake [this message]
2008-06-07 16:04 ` Simon Wright
2008-06-07 21:50 ` snoopysalive
2008-06-08 11:09 ` Simon Wright
2008-06-09 22:38 ` snoopysalive
2008-06-10 5:40 ` Simon Wright
2008-06-14 8:45 ` snoopysalive
2008-06-06 18:16 ` Georg Bauhaus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox