Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: How to call the unary "::"?

49 views
Skip to first unread message
Message has been deleted

Marcel Mueller

unread,
May 2, 2015, 12:01:03 PM5/2/15
to
On 02.05.15 16.39, Stefan Ram wrote:
> How to call the »::« in
>
> ::std::cout
>
> ? The second »::« is the binary "scope resolution operator",
> but is the first unary one also called "scope resolution
> operator"?

I would do so.

> It seems both designations are used only once in whole
> draft, so there does not seem to have been taken great care
> to give this operator a consistent and proper name, although
> we should value the normative text higher than the text of a
> note and thus call it "unary scope operator".

Well, a slash in a path name may also be at the start of a path to
denote the root and no one gave him another name in that context.


Marcel

Ian Collins

unread,
May 2, 2015, 3:56:43 PM5/2/15
to
Stefan Ram wrote:
> How to call the »::« in
>
> ::std::cout

The superfluous scope resolution operator?

--
Ian Collins

Victor Bazarov

unread,
May 2, 2015, 4:59:13 PM5/2/15
to
On 5/2/2015 3:56 PM, Ian Collins wrote:
> Stefan Ram wrote:
>> How to call the »::« in
>>
>> ::std::cout
>
> The superfluous scope resolution operator?

In this case, probably. In general, it's not superfluous if it helps
the compiler to distinguish a global symbol from a local one:

int i = 42;
int main() {
double i = .14159;
::i = 666;
}

V
--
I do not respond to top-posted replies, please don't ask

Öö Tiib

unread,
May 2, 2015, 5:15:19 PM5/2/15
to
On Saturday, 2 May 2015 23:59:13 UTC+3, Victor Bazarov wrote:
> On 5/2/2015 3:56 PM, Ian Collins wrote:
> > Stefan Ram wrote:
> >> How to call the »::« in
> >>
> >> ::std::cout
> >
> > The superfluous scope resolution operator?

:)

> In this case, probably. In general, it's not superfluous if it helps
> the compiler to distinguish a global symbol from a local one:
>
> int i = 42;
> int main() {
> double i = .14159;
> ::i = 666;
> }

Actually the front :: is good for indicating that a generally useful
name (like 'rename', 'open', 'CreateFile' etc.) is meant as a global
name not local name. It is fine for clarity even when there are no such
name in local scope because it may make sense to use same name locally.

A programmer who creates and hides cryptic names like 'i' or even
some well-known library cryptic global names (like 'std', 'freopen' or
'snprintf') in more local scope deserves beating up and out.
It is anyway complication, confusion and headache to read the code
that practices such name-hiding so it should be rewritten not guarded
against.

Bo Persson

unread,
May 3, 2015, 2:31:47 AM5/3/15
to
On 2015-05-02 16:39, Stefan Ram wrote:
> How to call the »::« in
>
> ::std::cout
>
> ? The second »::« is the binary "scope resolution operator",
> but is the first unary one also called "scope resolution
> operator"?
>

It really IS the same operator in both places. It just so happens that
the global namespace has no name, so its position looks empty.


Bo Persson

Message has been deleted
0 new messages