Re: Ada-Singleton-Why does it work like this?



patrick.gunia@xxxxxxxxxxxxxx wrote:
Hi all,
I´m currently working on implementing several design patterns in Ada,
and I found some code concerning the Singleton-pattern when searching
through the posts of this group. I used this code and it all worked as
expected. My problem is, that I don´t ave any idea, why it does...here
is my code:

package Singleton is

type Singleton_Type (<>) is tagged limited private;
type Singleton_Access is access all Singleton_Type;

function return_Single return Singleton_Access;

procedure setValues(input : in out Singleton_Access; valueIN :
Integer; valueIN2 : Integer);
procedure print_something(input : Singleton_Access);


private
type Singleton_Type is tagged limited record
value : Integer;
value2 : Integer;
end record;

end Singleton;

This is a very poor solution to the problem. A much simpler solution is

package Singleton is
procedure Set (Value_1 : in Integer; Value_2 : in Integer);

procedure Print;
end Singleton;

--
Jeff Carter
"We use a large, vibrating egg."
Annie Hall
44
.



Relevant Pages

  • Re: Zuhairs ordered pairs
    ... Let x=then is singleton. ... Why you only read this definition, I have posted a lot of posts to ... Now you think that this definition is Kuratowski, ... I said that Kuratowski ordered pairs has the property of being ...
    (sci.logic)
  • Re: Ada-Singleton-Why does it work like this?
    ... through the posts of this group. ... Singleton is not needed in Ada. ... of corresponding package: ...
    (comp.lang.ada)
  • Re: Ada-Singleton-Why does it work like this?
    ... through the posts of this group. ... Singleton is not needed in Ada. ... of corresponding package: ...
    (comp.lang.ada)
  • Re: [PHP] Re: Singletons
    ... private function __construct ... Except that in one of my follow up posts I indicated that my singleton ... class was deriving from a class that had a public constructor. ...
    (php.general)
  • Re: Ada-Singleton-Why does it work like this?
    ... package Singleton is ...     procedure Print; ... There are child packages in Ada, ...
    (comp.lang.ada)