473,395 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Why :: ? Why not : ? Why not . ? <- less clutter ?!?

Hello,

Why does C++ use :: for members/methods why not just : ?

For example:

long Test::TimesOne() const { return mVal; }

Alternative:

long Test:TimesOne() const { return mVal; }

Why use : at all ? Why not stick to . ?

long Test.TimesOne() const { return mVal; }

^^^ Less clutter ^^^

Bye,
Skybuck.
Aug 24 '07 #1
13 1299
Skybuck Flying wrote:
Why does C++ use :: for members/methods why not just : ?

For example:

long Test::TimesOne() const { return mVal; }

Alternative:

long Test:TimesOne() const { return mVal; }

Why use : at all ? Why not stick to . ?

long Test.TimesOne() const { return mVal; }

^^^ Less clutter ^^^
Less clutter does not mean more clarity. Programming is not
photography.

Analogy: I believe that if you make all road signs round,
they will be more difficult to read than with their current,
several distinct shapes.

I lost the link to this wonderful essay on the complexity of
English and proposals to reduce it. It starts, as I recall
with the proposal to replace 'c' with 'k' and 's' to reflect
the sounds it makes. Then it goes on to propose replacing
some diphthongs with single vowels or 'th' with 'z', and so
forth. Hillarious! Anyone knows where to find it?..

I googled for it, and I found one. Check it out:
http://www.polishnews.com/text/humor...n_english.html

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 24 '07 #2
Making road signs round or square or triangular does not add or reduce
clutter.

The unnecessary :: () makes it definetly more harder to understand, write
and read it.

A good test would be:

Ask someone who is dislexies which one he prefers:

long Test::TimesOne()

or

long Test.TimesOne

Another example of C++ clutter is operator overloading <- horrible clutter.

Just remembering what clutter is needed to make it compile requires an
elephant's memory.

Bye,
Skybuck.
Aug 24 '07 #3
* Skybuck Flying:
Hello,

Why does C++ use :: for members/methods why not just : ?

For example:

long Test::TimesOne() const { return mVal; }

Alternative:

long Test:TimesOne() const { return mVal; }

Why use : at all ? Why not stick to . ?

long Test.TimesOne() const { return mVal; }

^^^ Less clutter ^^^
This choice is probably covered in Bjarne Stroustrup's "Design and
Evolution"-book.

But the short of it is that

Aug 24 '07 #4
On 2007-08-24 06:09, Skybuck Flying wrote:

Please quote the text you are replying to.
Making road signs round or square or triangular does not add or reduce
clutter.

The unnecessary :: () makes it definetly more harder to understand, write
and read it.

A good test would be:

Ask someone who is dislexies which one he prefers:

long Test::TimesOne()

or

long Test.TimesOne

Another example of C++ clutter is operator overloading <- horrible clutter.

Just remembering what clutter is needed to make it compile requires an
elephant's memory.
Yes, C++ might be a bit cluttered and a bit hard to read, but as Alf
explained there is an obvious reason for most of it. If you want an
language that is easier to read and understand there are many of those,
BASIC comes to mind. But then again, few of these simpler languages are
even close to C++ in popularity, or as powerful as C++.

It's true that most people probably never will get more than a basic
understanding of C++, and if you are dyslectic you'll have more problems
than most. But then again most people will never be fit enough to
participate in the Summer Olympics.

By the way, how do you mean that operator overloading increase the
clutter? I'd argue that it does exactly the reverse. Consider the
following two examples:

a = b * (c - d * e);

or

a = b.multiply(c.minus(d.multiply(e)));

The second example is what you get without operator overloading. I
remember when back in school I was implementing DSA using Java's
BigInteger (a class that can store arbitrary large integers). The
mathematical operations went over two lines and I'd was forced to spend
a lot of time to figure out why it didn't work (was a miss-placed
bracket). All the time I was wishing I was using C++ with overloaded
operators instead.

--
Erik Wikström
Aug 24 '07 #5
Skybuck Flying wrote:
[... Aw... C++ has so much "clutter" ...]

Just remembering what clutter is needed to make it compile requires an
elephant's memory.
I have worked on CAD programs most of my career so far. They usually
have more functionality than an individual would ever need. Some of
them require structured learning (while simpler ones you may be able
to pick up just by using), which reflects their complexity. I've seen
clients complain about that, mostly wanting to get through a casual
encounter with the program without paying too much attention. "Just
make it so it does what I want", is the recurring theme with those
folks. "Why do we need twenty ways to draw a friggin circle?", "All
those toolbars with all those buttons make my eyes and my head hurt!".

Well, yes, the more complex problems you want to solve, the more complex
your tools have to become. The more complexity there is in the tools,
the more time one has to spend becoming proficient in those. If you do
not want to spend all the time and the effort required to learn the tool
(or tools), that's fine. You won't be able to compete on the market
with those who did spend the time and effort, but then again, maybe you
don't want or don't need to. It is entirely your choice. Use some
other tools to solve your problem. There are plenty to choose from.

Just remember that a few millennia ago a man would have to run to move
faster. Now, unless one has the money to hire a chauffeur, one has to
deal with the automobile with all the clutter of controls in front of
him. Same goes with man's dwelling, a few millennia ago it was just
a cave with a hearth. Nowadays it's the clutter of furniture, not to
mention home appliances, different kinds of food in the refridgirator.
And don't get me started on the clothing we're wearing. I don't see
you complain about all THAT...

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 24 '07 #6
On Aug 24, 4:27 am, "Skybuck Flying" <s...@hotmail.comwrote:
Hello,

Why does C++ use :: for members/methods why not just : ?
For example:
long Test::TimesOne() const { return mVal; }
Alternative:
long Test:TimesOne() const { return mVal; }
Why use : at all ? Why not stick to . ?
long Test.TimesOne() const { return mVal; }
^^^ Less clutter ^^^
The : token marks case labels and access specifiers,
so it's out.

As regards :: vs ., you're presumably thinking of
the java/C# situation where . is indeed used, ie
MyClass.StaticFunc();

The reason this wouldn't work in C++ is because in
C++ (as opposed to Java/C#) you can do this:

class A {
int x;
} A;

Now if we used . in place of ::, A.x would be ambiguous.
Aug 24 '07 #7
Using operators vs writing the operator overloaders.

To write an operator overload one has to use lot's of clutter.

Bye,
Skybuck.
Aug 24 '07 #8
I have programmed overloaded operators in Delphi.

And Delphi uses a really simple way to overload operators.

Without too much clutter !

Delphi puts C++ to shame !

Bye,
Skybuck.
Aug 24 '07 #9
Skybuck Flying wrote:
I have programmed overloaded operators in Delphi.

And Delphi uses a really simple way to overload operators.

Without too much clutter !

Delphi puts C++ to shame !
Ah, that... Congratulations on your exceptional camouflage, troll.
You win this year's prize!
Bye,
Skybuck.
Bye, Sky#uck!
Aug 24 '07 #10

Skybuck Flying wrote:
I have programmed overloaded operators in Delphi.

And Delphi uses a really simple way to overload operators.

Without too much clutter !

Delphi puts C++ to shame !
Yawn...

Aug 24 '07 #11

"tragomaskhalos" <da*************@logicacmg.comwrote in message
news:11**********************@e9g2000prf.googlegro ups.com...
On Aug 24, 4:27 am, "Skybuck Flying" <s...@hotmail.comwrote:
>Hello,

Why does C++ use :: for members/methods why not just : ?
For example:
long Test::TimesOne() const { return mVal; }
Alternative:
long Test:TimesOne() const { return mVal; }
Why use : at all ? Why not stick to . ?
long Test.TimesOne() const { return mVal; }
^^^ Less clutter ^^^

The : token marks case labels and access specifiers,
so it's out.

As regards :: vs ., you're presumably thinking of
the java/C# situation where . is indeed used, ie
MyClass.StaticFunc();

The reason this wouldn't work in C++ is because in
C++ (as opposed to Java/C#) you can do this:

class A {
int x;
} A;
Not sure what this means, I have't programmed in C++ for a pretty long time,
so I'll assume it means:

The first A is the class name, X is the field, the second A is a variable.
Now if we used . in place of ::, A.x would be ambiguous.
Why would it be ambigous ?

A.x can only be the field ?

Since I assume if one meant static class A.x one would have to use special
keywords.

Bye,
Skybuck.
Aug 24 '07 #12
On 2007-08-24 22:56, Skybuck Flying wrote:

Please quote the text you are replying to.
Using operators vs writing the operator overloaders.

To write an operator overload one has to use lot's of clutter.
A small sacrifice to avoid the more clutter later on. And the amount of
clutter the operator overload generates is debatable.

--
Erik Wikström
Aug 24 '07 #13
On 24 Aug, 22:09, "Skybuck Flying" <s...@hotmail.comwrote:
"tragomaskhalos" <dave.du.verg...@logicacmg.comwrote in message
class A {
int x;
} A;

... I'll assume it means:
The first A is the class name, X is the field, the second A is a variable.
Exactly.
Now if we used . in place of ::, A.x would be ambiguous.
Why would it be ambigous ?
A.x can only be the field ?
No. in a ". for ::" world A.x could mean EITHER the int x
inside the A variable (ie the field as you denote it) OR
the int x inside the A class, ie the int x inside ANY
instance of the class A. You may think that the latter
interpretation is meaningless, but this is precisely what
is required when declaring a pointer to member.
See Design & Evolution of C++ pg 95.
>
Since I assume if one meant static class A.x one would have
to use special keywords.
Now you've lost me - static hasn't got anything to do with it.
Aug 25 '07 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Christian Schmidbauer | last post by:
Hello! I prepare my XML document like this way: ------------------------------------------------------- PrintWriter writer; Document domDocument; Element domElement; // Root tag
4
by: matatu | last post by:
Hi to all, I have a xml file, a substring like: &lt;a href=&quot;#&quot;&gt;text&lt;/a&gt; which after an xslt trasform is rendered as (using xsl:output method html): &lt;a...
2
by: Eshrath | last post by:
Hi, What I am trying to do: ======================= I need to form a table in html using the xsl but the table that is formed is quite long and cannot be viewed in our application. So we are...
2
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script...
4
by: higabe | last post by:
Three questions 1) I have a string function that works perfectly but according to W3C.org web site is syntactically flawed because it contains the characters </ in sequence. So how am I...
11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
3
by: shaun roe | last post by:
a follow up with new problems from my previous post: I have xml encoded in a string with elements like &lt;myElement/&gt; e.g <codeFragment> &lt;myElement&gt;some text&lt;/myElement&gt; </codeFragment> I...
10
by: Jon Noring | last post by:
Out of curiosity, may a CDATA section appear within an attribute value with datatype CDATA? And if so, how about other attribute value datatypes which accept the XML markup characters? To me,...
9
by: Eric Lindsay | last post by:
I can't figure how to best display little snippets of shell script using <pre>. I just got around to organising to bulk validate some of my web pages, and one of the problems occurs with Bash...
6
by: tentstitcher | last post by:
Hi all: I have a source xml document with an element of type string. This element contains something like the following: <stringData> &lt;Header&gt; &lt;Body&gt; </stringData> I would like to apply an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.