comp.lang.ada
 help / color / mirror / Atom feed
From: Dale Stanbrough <dale@rmit.edu.au>
Subject: How to dynamically dispatch?
Date: 16 Mar 1995 06:36:31 GMT
Date: 1995-03-16T06:36:31+00:00	[thread overview]
Message-ID: <3k8m9f$eci@goanna.cs.rmit.edu.au> (raw)

I'm currently having problems figuring out how to dispatch
to the appropriate routines for the package (based on an
example in the LRM) below...

package expression is

        type expression is tagged null record;

        type literal is new Expression with
                record
                        value   :integer;
                end record;
        function eval(item:literal) return integer;

        type Expr_ptr is access all Expression'class;

        type binary_operation is new Expression with
                record
                        Left, Right: Expr_ptr;
                end record;

        type addition is new Binary_operation with null record;
        function eval(item:addition) return integer;

        type subtraction is new binary_operation with null record;
        function eval(item:subtraction) return integer;
end;

The body is....

package body expression is

        function eval(item:literal) return integer is
        begin
                return item.value;
        end;

        function eval(item:addition) return integer is
        begin
                return eval(item.left.all) + eval(item.right.all);
        end;

        function eval(item:subtraction) return integer is
        begin
                return eval(item.left.all) - eval(item.right.all);
        end;
end;

...but Gnat just says "invalid parameter list in call" for each
of the eval calls. To me this seems the same the example in
"Introducing Ada9x" in section 2.2.

Any thoughts?

Dale



             reply	other threads:[~1995-03-16  6:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-03-16  6:36 Dale Stanbrough [this message]
1995-03-17 10:37 ` How to dynamically dispatch? Samuel Tardieu
replies disabled

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