comp.lang.ada
 help / color / mirror / Atom feed
* Publishing selected entries in a protected object?
@ 2012-02-09 11:56 Jacob Sparre Andersen
  2012-02-09 13:42 ` Dmitry A. Kazakov
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jacob Sparre Andersen @ 2012-02-09 11:56 UTC (permalink / raw)


I have a package containing a protected object, and I would like to
publish _one_ of this object's entries in the specification of the
package.

Since I want to be able to use the entry in a select statement, I can't
just encapsulate it in a procedure and make that available in the
package specification.

And if I move the declaration of the protected object to the package
specification, but move the other entries to the private part of the
protected object, I can't access the other entries from the private part
of my package.

Is there a pattern I can use?

Thanks in advance,

Jacob
-- 
"You know the world has gone crazy when the best rapper is a
 white guy, the best golfer is a black guy, the swiss hold
 the America's cup, France is accusing the U.S. of
 arrogance, and Germany doesn't want to go to war"



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

* Re: Publishing selected entries in a protected object?
  2012-02-09 11:56 Publishing selected entries in a protected object? Jacob Sparre Andersen
@ 2012-02-09 13:42 ` Dmitry A. Kazakov
  2012-02-09 13:59 ` Georg Bauhaus
  2012-02-09 19:29 ` Jeffrey Carter
  2 siblings, 0 replies; 6+ messages in thread
From: Dmitry A. Kazakov @ 2012-02-09 13:42 UTC (permalink / raw)


On Thu, 09 Feb 2012 12:56:06 +0100, Jacob Sparre Andersen wrote:

> I have a package containing a protected object, and I would like to
> publish _one_ of this object's entries in the specification of the
> package.
> 
> Since I want to be able to use the entry in a select statement, I can't
> just encapsulate it in a procedure and make that available in the
> package specification.
> 
> And if I move the declaration of the protected object to the package
> specification, but move the other entries to the private part of the
> protected object, I can't access the other entries from the private part
> of my package.
> 
> Is there a pattern I can use?

Not exactly, but ...

   type I is protected interface;
   procedure A (X : in out I) is abstract;

   protected type Foo is new I with
      overriding entry A; -- "Public entry"
      entry B; -- "Private entry"
   end Foo;

Now, if only the interface I is visible, then that would be close to what
you wanted.

P.S. Alas, but the following is illegal:

   [protected] type Foo is new I with private;
private
   protected type Foo is new I with ... end Foo;

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: Publishing selected entries in a protected object?
  2012-02-09 11:56 Publishing selected entries in a protected object? Jacob Sparre Andersen
  2012-02-09 13:42 ` Dmitry A. Kazakov
@ 2012-02-09 13:59 ` Georg Bauhaus
  2012-02-09 18:24   ` AdaMagica
  2012-02-10  1:29   ` Randy Brukardt
  2012-02-09 19:29 ` Jeffrey Carter
  2 siblings, 2 replies; 6+ messages in thread
From: Georg Bauhaus @ 2012-02-09 13:59 UTC (permalink / raw)


On 09.02.12 12:56, Jacob Sparre Andersen wrote:
> I have a package containing a protected object, and I would like to
> publish _one_ of this object's entries in the specification of the
> package.


Using synchronized interfaces should work?


package Semi is

   type Half is synchronized interface;

   procedure Grab (PO : in out Half) is abstract;

   function MakePO return Half'Class;

private

   protected type Full is new Half with
     overriding
     entry Grab;

     entry Foo;
   end Full;

end Semi;

...

   function MakePO return Half'Class is
   begin
      return Result : Full;
   end MakePO;





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

* Re: Publishing selected entries in a protected object?
  2012-02-09 13:59 ` Georg Bauhaus
@ 2012-02-09 18:24   ` AdaMagica
  2012-02-10  1:29   ` Randy Brukardt
  1 sibling, 0 replies; 6+ messages in thread
From: AdaMagica @ 2012-02-09 18:24 UTC (permalink / raw)


On 9 Feb., 14:59, Georg Bauhaus <rm.dash-bauh...@futureapps.de> wrote:
> On 09.02.12 12:56, Jacob Sparre Andersen wrote:
>
> > I have a package containing a protected object, and I would like to
> > publish _one_ of this object's entries in the specification of the
> > package.
>
> Using synchronized interfaces should work?
>
> package Semi is
>
>    type Half is synchronized interface;
>
>    procedure Grab (PO : in out Half) is abstract
       with Synchronization => By_entry;  -- Ada 2012 9.5(10/3)
>
>    function MakePO return Half'Class;
>
> private
>
>    protected type Full is new Half with
>      overriding
>      entry Grab;
>
>      entry Foo;
>    end Full;
>
> end Semi;
>
> ...
>
>    function MakePO return Half'Class is
>    begin
>       return Result : Full;
>    end MakePO;




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

* Re: Publishing selected entries in a protected object?
  2012-02-09 11:56 Publishing selected entries in a protected object? Jacob Sparre Andersen
  2012-02-09 13:42 ` Dmitry A. Kazakov
  2012-02-09 13:59 ` Georg Bauhaus
@ 2012-02-09 19:29 ` Jeffrey Carter
  2 siblings, 0 replies; 6+ messages in thread
From: Jeffrey Carter @ 2012-02-09 19:29 UTC (permalink / raw)


On 02/09/2012 04:56 AM, Jacob Sparre Andersen wrote:
> I have a package containing a protected object, and I would like to
> publish _one_ of this object's entries in the specification of the
> package.
>
> Since I want to be able to use the entry in a select statement, I can't
> just encapsulate it in a procedure and make that available in the
> package specification.
>
> And if I move the declaration of the protected object to the package
> specification, but move the other entries to the private part of the
> protected object, I can't access the other entries from the private part
> of my package.

package P is
    protected Public is
       entry E;
    end Public;
end P;

package body P is
    protected Hidden is
       entry E;
       entry Internal;
    private -- Hidden
       ...
    end Hidden;

    protected body Public is
       entry E when True is
          -- null;
       begin -- E
          requeue Hidden.E [with abort];
       end E;
    end Public;

    ...
end P;


-- 
Jeff Carter
"IMHO, Interfaces are worthless."
Randy Brukardt
117

--- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---



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

* Re: Publishing selected entries in a protected object?
  2012-02-09 13:59 ` Georg Bauhaus
  2012-02-09 18:24   ` AdaMagica
@ 2012-02-10  1:29   ` Randy Brukardt
  1 sibling, 0 replies; 6+ messages in thread
From: Randy Brukardt @ 2012-02-10  1:29 UTC (permalink / raw)


"Georg Bauhaus" <rm.dash-bauhaus@futureapps.de> wrote in message 
news:4f33d158$0$7625$9b4e6d93@newsspool1.arcor-online.net...
> On 09.02.12 12:56, Jacob Sparre Andersen wrote:
>> I have a package containing a protected object, and I would like to
>> publish _one_ of this object's entries in the specification of the
>> package.
>
>
> Using synchronized interfaces should work?

It will often work, but there are some problems. We couldn't get the design 
of the Queue containers to work out properly, and we ended up with the 
horrifically ugly "Implementation" package.

I think that can be fixed, but it will require some new capabilities for 
protected types, and those may cause other problems. Oh well, Ada has to 
have some problems or the ARG wouldn't need an editor, and then I'd have to 
find some real work. ;-)

                                          Randy.





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

end of thread, other threads:[~2012-02-10  1:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-09 11:56 Publishing selected entries in a protected object? Jacob Sparre Andersen
2012-02-09 13:42 ` Dmitry A. Kazakov
2012-02-09 13:59 ` Georg Bauhaus
2012-02-09 18:24   ` AdaMagica
2012-02-10  1:29   ` Randy Brukardt
2012-02-09 19:29 ` Jeffrey Carter

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