🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #153

Re: How About a Pragma Specifying All Functions Virtual?

#153
From: Steve Clamage
Date: Sat, 12 Sep 1992 18:05
34 lines
1828 bytes
feustel@netcom.com (David Feustel) writes:

>Coplien's book "Advanced C++" makes the point that very little overhead
>would be incurred in most programe even if all functions were declared
>virtual and that some programs might even run faster than equivalent C
>programs using switch constructs to achieve the same effects. Why not
>define a pragma that would make all class functions virtual by
>default?

Nothing prevents a C++ implementation from providing such a pragma.

But IMHO pragmas which change language semantics are very dangerous.

1.  If you miss including the pragma in one place, or remove it
    from all but one place, you can get bizarre program failures,
    not necessarily caught in testing.

2.  If the code moves to another compiler which doesn't support the
    pragma, it will be silently ignored and the program will have a
    different meaning.  If you are very lucky, the compiler will
    warn about the pragma, or the program will fail in testing.
    (In Standard C, unknown pragmas are not errors.)

3.  The code might move to a compiler which has the same pragma, but
    with a different meaning.  Example:
	#pragma once
    Everybody knows this pragma, right?  It turns on special features
    for the customer engineer.  You turn them off again with
	#pragma offce
    (I didn't think this one up, but it's my favorite.)
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
Vice Chair, ANSI C++ Committee, X3J16
Technical Details
Message-ID: <1992Sep12.180508.6483@taumet.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!taumet!steve
References: <#7vnafk.feustel@netcom.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++
Path: arc1-ca.pugleaf.net!sparky!uunet!taumet!steve
From: steve@taumet.com (Steve Clamage)
Subject: Re: How About a Pragma Specifying All Functions Virtual?
Message-ID: <1992Sep12.180508.6483@taumet.com>
Organization: TauMetric Corporation
References: <#7vnafk.feustel@netcom.com>
Date: Sat, 12 Sep 1992 18:05:08 GMT
Lines: 34