From -8269917926568442319
X-Google-Thread: 7894ca11fe,ad25a0efe0463aca
X-Google-Attributes: gid7894ca11fe,public,usenet
X-Google-NewGroupId: yes
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news2.google.com!news2.google.com!news.glorb.com!news.alt.net!frodo.cs.rpi.edu!not-for-mail
From: Francis Glassborow <francis.glassborow@btinternet.com>
Newsgroups: comp.std.c++
Subject: Re: New range-based for and the creation of another kind of "magic"   function
Date: Mon,  3 Aug 2009 12:16:35 CST
Organization: unknown
Lines: 60
Sender: cppmods@cs.rpi.edu
Approved: austern@google.com
Message-ID: <kKCdndPz94TMT-vXnZ2dnUVZ8iednZ2d@bt.com>
References: <404cca88-36b3-4708-8748-8f15edac2ec4@a37g2000prf.googlegroups.com>
NNTP-Posting-Host: netlab.cs.rpi.edu
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
To: (Usenet)
Return-Path: <cppmods@ruralroute.cs.rpi.edu>
X-Original-Date: Mon, 03 Aug 2009 13:04:30 +0100
X-Submission-Address: std-c++@netlab.cs.rpi.edu
Xref: g2news2.google.com comp.std.c++:1211

Sean Hunt wrote:
> Disclaimer: I have not yet seen N2930.
>
> With concepts removed from C++1x, range-based for has been downgraded
> to an ADL-based solution. While I generally like the idea, my primary
> concern is that it creates a new kind of "magic" function - that is,
> one that has special meaning to the language.

Actually concepts have been removed from C++0x and are quite likely to
be included in C++1x when we get there. I am not nit-picking. The name
we use to refer to a project matters and in this case it is that the
release of the C++ Standard currently being worked on is code named
C++0x. Changing that mid stream because of delayed delivery will just
cause confusion.

>
> Currently, C++ has a dearth of "magic" functions. These allow the C++
> language to assign special properties to them that other functions do
> not have. There are four basic types of magic functions in the
> language: ::main(), constructors, destructors, and operator functions
> (While there are at least four different types of functions that are
> defined with the operator keyword, they can be grouped together for
> the purposes of this discussion). Every one of these functions is
> specified using a special syntax - there is no ability to mistake it
> for a "normal" function with no significance to the language.

While I agree with you that ::main() is special (in that it cannot be
called and falling off the end of it is not an error) and ctors are
special (no return type) and dtors are somehow special because of the
way they chain together how are operator functions special? OK they have
two token names but, IMO, not much else is special about them.

>
> I will use the term "magic function" in the remainder of this post to
> refer to any function with special language-defined semantics that
> differ from ordinary functions, and "magic name" to refer to any name
> which, if a function has it, may result in the function being magic.

OK, but I have always understood 'magic' to refer to an implementation
that cannot be written in C++ and so needs some under the cover action
by the implementation.

>
> The new range proposal creates a for loop with syntax "for (i : vec)"
> which will, for a vec of a user--defined type, cause an implicit
> lookup of begin(vec) and end(vec), but using only argument-dependent
> lookup - that is, only functions in the same namespace as vec will be
> considered. This makes begin and end into magic names - the first two
> such names in C++, other than ::main().
>

Your argument seems to be very convoluted. I wonder if you can rewrie it
focusing on the major issues.

-- 
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



