public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Gianni Mariani <gmariani@chaincast.com>
Cc: gcc@gcc.gnu.org
Subject: Re: c++ "with" keyword
Date: Sat, 04 Jan 2003 17:35:00 -0000	[thread overview]
Message-ID: <3E171A85.8030008@chaincast.com> (raw)
In-Reply-To: <15894.64524.464371.216489@cuddles.cambridge.redhat.com>

Andrew Haley wrote:

>Momchil Velikov writes:
> > >>>>> "Robert" == Robert Dewar <dewar@gnat.com> writes:
> > 
> >     Robert> If you think "with" is valuable, then the task is to
> >     Robert> convince the guardians of the C++ standard of this. If
> >     Robert> you can't convince the
> > 
> > Not related to this particular "with" discussion, but I couldn't
> > disagree more.  A standards body should not invent language
> > "features", but rather codify existing (proven) extensions.
>
>I totally agree.  A standards should not invent language features, or
>-- heaven forbid -- programming languages.  The reason for this is
>pretty obvious, in that once a feature is standardized it's too late
>to remove it if it has some fatal flaw.
>  
>
I agree as well.

Proposals of language extensions should come from anyone :)  The metrits 
discussed in community and accepted as a standard once it is generally 
accepted.

So, I'd like to steer the discussion back to the merits of "with".

The "with" syntax was a pain in the rear in Pascal and I never want to 
see it again - this is why:

Take 2 structures, A and B which are both used in a "with" statement.

e.g. (I'll use the proposed new "with" syntax in c++ below)

Let's start with some valid working code ...

struct A {
    int    X;
    int    Y;
    int    hUgH;
};

struct B {
    int    Z;
};

int func()
{
        ....
        A & a;
        B & b;
        ....

        with ( a )
        witb ( b )
        {

            Y = Z;
            hUgH = X; //  woz this then eh ? <-- point of confusion
        }
        ...
}

And a little later someone comes and fixes a bug and adds

struct B {
    int    Z;
    int    X;    // need an X to fix The Bug (tm)
};

Oops - which X is now instantiated at "point of confusion" ?

Someone innocently added a new member and completly changed the 
behaviour of the code.  For code maintainability, I'd suggest that this 
would cause more difficult to discover problems than would be merited.

This is also one of the reasons I don't like namespaces much either - 
hence I allways prefix identifiers that are not within a class's scope.

If you were to implement (heaven forbid) the "with" mechanism, I'd 
suggest you use the "using" keyword instead.

G


  parent reply	other threads:[~2003-01-04 17:32 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-04 14:29 Robert Dewar
2003-01-04 15:00 ` Momchil Velikov
2003-01-04 15:24   ` Andrew Haley
2003-01-04 16:25     ` Neil Booth
2003-01-04 17:35     ` Gianni Mariani [this message]
2003-01-04 17:59       ` Tolga Dalman
2003-01-04 18:36         ` Gianni Mariani
2003-01-04 18:54           ` Tolga Dalman
2003-01-04 23:32         ` Kevin Handy
2003-01-14 14:33 ` Fergus Henderson
  -- strict thread matches above, loose matches on Subject: below --
2003-01-06 13:07 Robert Dewar
2003-01-05 18:41 Robert Dewar
2003-01-05 13:03 Robert Dewar
2003-01-05 13:39 ` Toon Moene
2003-01-05 12:56 Robert Dewar
2003-01-06 12:18 ` Andrew Haley
2003-01-05 12:56 Robert Dewar
2003-01-05 18:22 ` Joseph S. Myers
2003-01-05 12:44 Robert Dewar
2003-01-05  3:16 Robert Dewar
2003-01-05  0:38 Robert Dewar
2003-01-05  0:29 Robert Dewar
2003-01-05  0:37 ` Kevin Handy
2003-01-04 23:27 Robert Dewar
2003-01-04 23:36 ` Lynn Winebarger
2003-01-05  2:55 ` Gianni Mariani
2003-01-04 22:13 Robert Dewar
2003-01-04 20:59 Robert Dewar
2003-01-04 22:36 ` Gianni Mariani
2003-01-04 20:09 Robert Dewar
2003-01-04 19:36 Robert Dewar
2003-01-04 19:59 ` Tolga Dalman
2003-01-04 19:13 Robert Dewar
2003-01-04 20:58 ` Gianni Mariani
2003-01-04 18:11 Robert Dewar
2003-01-04 18:47 ` Gianni Mariani
2003-01-04 17:52 Robert Dewar
2003-01-04 17:59 ` Gianni Mariani
2003-01-04 17:06 Robert Dewar
2003-01-04 17:22 ` Daniel Berlin
2003-01-05 11:33 ` Andrew Haley
2003-01-05 11:36   ` Toon Moene
2002-12-29  8:32 Norman Jonas
2002-12-29 12:46 ` Russ Allbery
2002-12-29  6:49 Erik Schnetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3E171A85.8030008@chaincast.com \
    --to=gmariani@chaincast.com \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).