Topic: final syntax (Was: final)


Author: Valentin Bonnard <Bonnard.V@wanadoo.fr>
Date: 1999/07/24
Raw View
Lisa Lippincott wrote:

> I think the word "final" is being overburdened in this discussion.  Given
> classes X and Y, can one declare a member function X::F with all of these
> properties?
>
>    X::F may only be called on objects of exact type X

This is the final _after_ the function name:

class A {
    int foo () final;
};

>    X::F returns a pointer to an object of exact type Y
>    X::F may not be overriden

Yeep, you discovered a pretty serious syntax ambiguity:

    final int foo ();

can mean either

    typedef final int fint; // fint is a synonym for int

    fint foo ();

or

    what_follows_is_a_final_function int foo ();

I suggest ``exact'' when applied to types:

    typedef exact int eint; // eint is a synonym for int

    void foo () exact;

and final for functions:

    final void foo ();

But this problem is purely syntaxic, and doesn't affect the
semantics.

--

Valentin Bonnard
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]