comp.lang.ada
 help / color / mirror / Atom feed
* Why can't I override these functions?
@ 2004-05-07 10:43 Björn Persson
  2004-05-07 17:15 ` Jim Rogers
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Björn Persson @ 2004-05-07 10:43 UTC (permalink / raw)


I have a generic package with a tagged type Parameter_Definition, a 
generic subpackage with a type Intermediate_Definition derived from 
Parameter_Definition, and a generic child package with a type 
Typed_Parameter_Definition derived from Intermediate_Definition. See the 
code below. Gnat gives me an error on the declaration of 
Typed_Parameter_Definition:

extracted-discrete_parameters.ads:19:09: type must be declared abstract 
or "Meaning" overridden

But I *have* overridden that function! It's right there on line 23! If I 
take Meaning away I get the same error saying that Default must be 
overridden, which I have also done. I must be stupid because I can't see 
why these functions don't count as overriding. Either that or the error 
message is misleading and the error is really something else. Could 
somebody please explain this?


Here's the code. I have removed lots of stuff that doesn't affect the 
error message:


with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;

generic
    type Parameter_Name is (<>);
package Extracted is


private

    type Parameter_Definition(mandatory, multiple : boolean) is
      abstract tagged record
       Description : Unbounded_String;
    end record;
    type Parameter_Definition_Pointer is access all 
Parameter_Definition'class;

    type Value_Wrapper is tagged null record;
    type Value_Wrapper_Pointer is access all Value_Wrapper'class;


    function Meaning(Def : Parameter_Definition;
                     Name : Parameter_Name;
                     Text : Unbounded_String)
                     return Value_Wrapper_Pointer is abstract;

    function Meaning_Valueless(Def : Parameter_Definition;
                               Name : Parameter_Name)
                               return Value_Wrapper_Pointer;

    function Default(Def : Parameter_Definition)
                     return Value_Wrapper_Pointer is abstract;


    --
    -- Common_Functions
    --

    generic
       type Value_Type is private;
       type Array_Type is array(positive range <>) of Value_Type;
       type Wrapper_Type is new Value_Wrapper with private;
       with function Content(Wrapper : Wrapper_Type) return Value_Type;
    package Common_Functions is

       type Intermediate_Definition(mandatory, multiple : boolean) is
       abstract new Parameter_Definition(mandatory, multiple) with record
          case mandatory is
             when false =>
                case multiple is
                   when false =>
                      Default : Value_Type;
                   when true =>
                      null;
                end case;
             when true =>
                null;
          end case;
       end record;

    end Common_Functions;

end Extracted;


with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;

generic
    type The_Type is (<>);
package Extracted.Discrete_Parameters is

    type Vector is array(Positive range <>) of The_Type;

private
    type Typed_Wrapper is new Value_Wrapper with record
       Value : The_Type;
    end record;

    function Content(Wrapper : Typed_Wrapper) return The_Type;

    package Funcs is new Common_Functions
      (The_Type, Vector, Typed_Wrapper, Content);
                  -- This is line 18. Error on line 19 below. ---------
    type Typed_Parameter_Definition(mandatory, multiple : boolean) is
      new Funcs.Intermediate_Definition(mandatory, multiple) with
      null record;

    function Meaning(Def : Typed_Parameter_Definition;  -- line 23
                     Name : Parameter_Name;
                     Text : Unbounded_String)
                     return Value_Wrapper_Pointer;

    function Default(Def : Typed_Parameter_Definition)
                     return Value_Wrapper_Pointer;

end Extracted.Discrete_Parameters;

-- 
Björn Persson

jor ers @sv ge.
b n_p son eri nu




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

end of thread, other threads:[~2004-05-13  7:23 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-07 10:43 Why can't I override these functions? Björn Persson
2004-05-07 17:15 ` Jim Rogers
2004-05-07 18:15   ` Björn Persson
2004-05-07 18:42 ` Georg Bauhaus
2004-05-07 19:38   ` Björn Persson
2004-05-08  6:15     ` Martin Krischik
2004-05-09 12:42       ` Björn Persson
2004-05-08 11:34     ` Simon Wright
2004-05-09 12:38       ` Björn Persson
2004-05-10  5:43         ` Simon Wright
2004-05-10 11:49 ` Martin Dowie
2004-05-10 12:13   ` Björn Persson
2004-05-13  7:23 ` Björn Persson

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