473,385 Members | 1,311 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,385 software developers and data experts.

Empty arguments

Hi group,
Almost 3 weeks ago I posted a short question here and in comp.std.c++
and I got exactly 1 respons, from Kevin Goodsell. He said he didn't want
it. I post it here again, this time in a thread named 'Empty arguments', because
that is what I got from you. Can you spare a minute and try to see my point?

struct Room
{
Room(bool a=true,bool b=true,bool c=true):Chair(a),Table(b),Bed(c){}
bool Chair,Table,Bed;
};
int main()
{
Room bedroom; //chair, table, bed
Room living(,,false); //no bed in the living
Room guestroom(,false,); //chair, bed, no table, no running water
Room toilet(,false,false); //no table, no bed
return 0;
}

The defective use of arguments above is a trivial case. I fill my
Windows structs in a function call and give a default value to each
formal argument. I want to apply a more elaborate use of default
arguments, but I am hindered by the fact that C++ does not allow
empty arguments.

Empty arguments would enable you to have one constructor or function
for whatever number and combination of arguments. You must only fill
in the non-default values and seperate them with the appropriate
number of comma's.

The semantics of this code is easily understood but the syntax is not
allowed in C++. The Annotated C++ Reference Manual:

<ARM 8.2.6>
It was felt that having empty arguments significant was not
only too subtle, but seriously decreased the opportunities
for detecting errors; an extra comma in an argument list is
not an unusual result of bad typing or sloppy editing.
</>

I don't agree on it being too subtle. It's only a matter of
counting comma's. I do feel a little offended however that the
language anticipates on my sloppy typing. There is a real need
for more flexible default arguments. The reasons not to have
them are not convincing enough.
-----------

Why does nobody fire up his typewriter, think about something
annoying for a moment and type

YOU WON'T GET IT MULDER!!! IT'S TOO F#@%ING SIMPLE !!!!

or something along those lines. It will be better than non-existant replies
till now.

Thank you,

-X
Jul 19 '05 #1
10 3242
Agent Mulder wrote:
Hi group,
Almost 3 weeks ago I posted a short question here and in comp.std.c++
and I got exactly 1 respons, from Kevin Goodsell. He said he didn't
want
it. I post it here again, this time in a thread named 'Empty
arguments', because that is what I got from you. Can you spare a
minute and try to see my point?

struct Room
{
Room(bool a=true,bool b=true,bool c=true):Chair(a),Table(b),Bed(c){}
bool Chair,Table,Bed;
};
int main()
{
Room bedroom; //chair, table, bed
Room living(,,false); //no bed in the living
Room guestroom(,false,); //chair, bed, no table, no running
water
Room toilet(,false,false); //no table, no bed
return 0;
}

The defective use of arguments above is a trivial case. I fill my
Windows structs in a function call and give a default value to each
formal argument. I want to apply a more elaborate use of default
arguments, but I am hindered by the fact that C++ does not allow
empty arguments.

Empty arguments would enable you to have one constructor or function
for whatever number and combination of arguments. You must only fill
in the non-default values and seperate them with the appropriate
number of comma's.

The semantics of this code is easily understood but the syntax is not
allowed in C++. The Annotated C++ Reference Manual:

<ARM 8.2.6>
It was felt that having empty arguments significant was not
only too subtle, but seriously decreased the opportunities
for detecting errors; an extra comma in an argument list is
not an unusual result of bad typing or sloppy editing.
</>

I don't agree on it being too subtle. It's only a matter of
counting comma's. I do feel a little offended however that the
language anticipates on my sloppy typing. There is a real need
for more flexible default arguments. The reasons not to have
them are not convincing enough.
-----------
You don't understand it, that is OK. But this is exactly the point why
empty arguments are not allowed. Since in a function having many arguments
with defaults 5 commas and a value and 4 commas and a value could end up be
both correct for the compiler, but not for runtime. And finding that error
is subtle.

BTW if you are frustrated by the way Microsoft defines their Windows
structure... well, you will need to complain there.
Why does nobody fire up his typewriter, think about something
annoying for a moment and type

YOU WON'T GET IT MULDER!!! IT'S TOO F#@%ING SIMPLE !!!!

or something along those lines. It will be better than non-existant
replies till now.


As far as I see you gave got all replies you have payed for.

--
Attila aka WW
Jul 19 '05 #2
Agent Mulder wrote:
Hi group,
Almost 3 weeks ago I posted a short question here and in comp.std.c++
and I got exactly 1 respons, from Kevin Goodsell. He said he didn't want
it. I post it here again, this time in a thread named 'Empty arguments', because
that is what I got from you. Can you spare a minute and try to see my point?


Donated a minute.

I don't believe that extensions to default arguments will provide any
further readability or significant reduced complexity of new code.

Instead of making the standard more difficult for programmers to
understand, I'd rather see it become simpler.

I'll also echo the point on typos.

Jul 19 '05 #3
<Gianni Mariani>
I don't believe that extensions to default arguments will provide any
further readability or significant reduced complexity of new code.
Instead of making the standard more difficult for programmers to
understand, I'd rather see it become simpler.

</>

You don't have to use it. And you can easily wrap up the uglies like
this:

void ugly(int a=0,bool b=true,char c='D',string d="Hello World"){}
void ugly(string a){ugly(,,,a);}

and use it like this

ugly("Goodbye World");

The comma counting part is confusing, that's true. There are
only three comma's in the argument list of the first version of
ugly. The syntax of C++ allows you to skip the comma's when
no actual arguments follow. Comma's before an override are
significant, of course.

There is a possible ambiguity looming, but it might get cornered
by syntax like this:

ugly(int,bool,char,"Farewell");

-X
Jul 19 '05 #4
In article <bl**********@news4.tilbu1.nb.home.nl>,
mb*******************@home.nl says...

[ ... ]
The semantics of this code is easily understood but the syntax is not
allowed in C++. The Annotated C++ Reference Manual:


You don't get it Mulder. This newsgroup is devoted to discussing how to
use the language the way it is defined now. If you want to discuss how
you think it should be defined, that's topical in comp.std.c++, but NOT
here.

Personally, I think trying to bring it up there is pretty much beating a
dead horse -- it's clearly been considered and rejected and it appears
that you have very little to say about why it was rejected other than "I
disagree". While you're certainly welcome to disagree, it doesn't (by
itself) make a very convincing argument.

I doubt that you could convince the committee on this one with much
short of concrete evidence. Just for example, if you were grab the
sources to gcc and modify it to accept the syntax you want, and then do
a study showing that using it reduced source code size by X% and bug
rates by Y%, then you'd at least give them a real reason to reconsider
the decision. I realize that you're probably more interested in using
compilers than (re)writing them, but that's how life goes sometimes --
if you really think it's worth fighting for, you can fight for it;
otherwise, you can live with it the way it is.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 19 '05 #5
<Jerry Coffin>
Just for example, if you were grab the
sources to gcc and modify it to accept the syntax you want, and then do
a study showing that using it reduced source code size by X% and bug
rates by Y%, then you'd at least give them a real reason to reconsider
the decision.

</>

I don't understand what you mean, but making empty arguments
significant won't break a single line of code, both written and
compiled. Some uncompilable code could jump into life, though.

-X
Jul 19 '05 #6
In article <bl**********@news1.tilbu1.nb.home.nl>,
mb*******************@home.nl says...

[ ... ]
I don't understand what you mean,


Which part of "off-topic" are you having trouble with?

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 19 '05 #7
On Mon, 29 Sep 2003 19:33:23 +0200, "Agent Mulder"
<mb*******************@home.nl> wrote in comp.lang.c++:
<Jerry Coffin>
Just for example, if you were grab the
sources to gcc and modify it to accept the syntax you want, and then do
a study showing that using it reduced source code size by X% and bug
rates by Y%, then you'd at least give them a real reason to reconsider
the decision.

</>

I don't understand what you mean, but making empty arguments
significant won't break a single line of code, both written and
compiled. Some uncompilable code could jump into life, though.

-X


There are either an infinite or near-infinite number (I don't have the
time to count them) of possible changes to the C++ language that won't
break a single line of code. That in itself does not in the least
justify adding anything at all to the language.

This has been proposed before, and bypassed before, on the grounds
that it adds little utility at the expense of increasing the chance
for errors.

The simple fact that you disagree and want this feature is absolutely
meaningless. You are free to stomp your foot or hold your breath
until you turn blue if you don't get your what you want, but that also
in itself does not justify adding anything to the language.

So here are three simple tips:

1. Take this to a group where it is topical, such as the already
suggested comp.std.c++, and out of here where it is not.

2. Understand that you are only expressing one point of view about an
issue that has many different points of view. The fact that a
language change will not break any existing conforming code is a plus,
but what is the cost to the implementor? Many of the members of
language standards committees are compiler vendors. They will not
vote for additions that are expensive to implement unless there is a
significant amount of popular support from their customers, the
programmers.

3. Standards committees tend to give much more weight to language
proposals where they are available as extensions in one or more
existing implementations to demonstrate the utility and workability of
the extension. If you feel that strongly about it, get involved in an
open source project like g++ and see if you can convince them to let
you add it to their compiler.

But whatever you do, stop whining about it here. You'll just get
yourself plonked if you keep it up.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
Jul 19 '05 #8
Tom
"Agent Mulder" <mb******@home.nl> wrote:
Almost 3 weeks ago I posted a short question here and in comp.std.c++
and I got exactly 1 respons, from Kevin Goodsell. He said he didn't want
it. I post it here again, this time in a thread named 'Empty arguments',
because
that is what I got from you. Can you spare a minute and try to see my point?

struct Room
{
Room(bool a=true,bool b=true,bool c=true):Chair(a),Table(b),Bed(c){}
bool Chair,Table,Bed;
};
int main()
{
Room bedroom; //chair, table, bed
Room living(,,false); //no bed in the living
Room guestroom(,false,); //chair, bed, no table, no running water
Room toilet(,false,false); //no table, no bed
return 0;
}

The defective use of arguments above is a trivial case. I fill my
Windows structs in a function call and give a default value to each
formal argument. I want to apply a more elaborate use of default
arguments, but I am hindered by the fact that C++ does not allow
empty arguments.

Empty arguments would enable you to have one constructor or function
for whatever number and combination of arguments. You must only fill
in the non-default values and seperate them with the appropriate
number of comma's.
[snip]
Why does nobody fire up his typewriter, think about something
annoying for a moment and type

YOU WON'T GET IT MULDER!!! IT'S TOO F#@%ING SIMPLE !!!!

or something along those lines. It will be better than non-existant replies
till now.


You know, Mr. Troll, last time you raised this topic, I told you to
find a copy of Stroustrup's Design and Evolution of C++. I'm
suggesting that to you again. Specifically, turn to Section 6.5.1 and
6.5.1.1 (pages 153-157), and read about the proposal to add keyword
arguments, which were proposed to address the problem you think needs
solving, why that addition to the language was rejected and - and this
is the important part - how you can achieve the functionality you
apparently desire, although not with your syntax.

Best regards,

Tom
Jul 19 '05 #9
<Tom>
you can achieve the functionality you apparently desire, although not with your syntax.
</Tom>

Hi Tom, you tireless trollhunter (is it because hairs grow between my toes?).
The syntax, 'my' syntax, is essential. Let me quote from the Annotated C++
Reference Manual again, this time with some more context:
<ARM 8.2.6>

The declaration

point (int = 3, int = 4);

declares a function that can be called with zero, one, or two arguments of type
int. It may be called in any of these ways:

point(1,2); point(1); point();

The last two calls are equivalent to point(1,4) and point(3,4), respectively.

The point function could equivalently have been declared like this:

point(int,int);
point(int, int = 4);
point(int = 3, int);

but not like this:

point(int,int);
point(
int = 3, //error: default argument not at end
int
);
point(int, int = 4);

or like this:

point(int,int);
point(int, int = 4);
point(
int = 3,
int = 4 //error: redefinition of default argument

C++ prohibits the obvious call syntax and semantics for calling point() given a
default value for only the first argument, which would be

point(,3); //syntax error

It was felt that having empty arguments significant was not
only too subtle, but seriously decreased the opportunities
for detecting errors; an extra comma in an argument list is
not an unusual result of bad typing or sloppy editing.

</ARM 8.2.6>

See my point? The syntax is essential for what I want. The reasons in
the ARM not to have it are very weak indeed. I hold my breath till it is
added to the language ;-)

-X


Jul 19 '05 #10
Tom
"Agent Mulder" <mb******@home.nl> wrote:
<Tom>
you can achieve the functionality you apparently desire, although not with
your syntax.
</Tom>

Hi Tom, you tireless trollhunter (is it because hairs grow between my toes?).
Hmm... touche.
The syntax, 'my' syntax, is essential.
"essential"? As in indispensible? No it isn't, because one can
accomplish what you want without your syntax. Perhaps you mean
"convenient." And my point is that Stroustrup suggests a reasonably
convenient way not to have to include all the default arguments -
which I take it is what you are after. And Stroustrup's specific
example is a call to an MS Windows window display function that
includes lots of arguments, with respect to most of which one usually
doesn't want to change the defaults.
Let me quote from the Annotated C++
Reference Manual again, this time with some more context:
[snip]
It was felt that having empty arguments significant was not
only too subtle, but seriously decreased the opportunities
for detecting errors; an extra comma in an argument list is
not an unusual result of bad typing or sloppy editing.

</ARM 8.2.6>

See my point? The syntax is essential for what I want.
No, I don't. Stroustrup presents in the D&EC++ a convenient way of
accomplishing what you want without changing the language. Without
even trying it or apparently even looking it up, you dismiss it and
say your syntax is "essential."
The reasons in the ARM not to have it are very weak indeed.
One thing one learns when reading D&EC++ is that one of Stroustrup's
primary goals in designing the language was to reduce stupid coding
errors. Strong type safety is merely one way to help achieve that
goal. Not adopting the syntax you suggest is another way to support
the same goal. It is not surprising that the choice was made not to
include the feature you want, especially when one can accomplish the
same thing in a convenient way without increasing the risk of stupid,
and most undetectable, syntax errors through inadvertantly omitted
commas.
I hold my breath till it is added to the language.


Good. Please keep doing so. I would like to say I would hold my
breath until you actually look at D&EC++, but I would undoubtedly
suffocate.

Best regards,

Tom
Jul 19 '05 #11

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

Similar topics

1
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I...
3
by: tornado | last post by:
Hi all, I am pretty new to PHP. I was reading PHP manual and trying out the example from 2nd chapter (A simple Tutorial). When i try to print the variable as given in the example it returns...
25
by: Sabyasachi Basu | last post by:
While trying to port some stuff from Unix to Windows, I encountered a strange behaviour of function macros with empty arguments. Here is a small snippet which illustrates the problem: #include...
23
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to...
0
by: riccoi | last post by:
Hi. I had created a Windows Application ant put there the code down there. I am trying to get information about the processes that are currently running in my machine. The problem is: ...
12
by: Stefan Weiss | last post by:
Hi. (this is somewhat similar to yesterday's thread about empty links) I noticed that Tidy issues warnings whenever it encounters empty tags, and strips those tags if cleanup was requested....
14
by: cj | last post by:
What is string.empty used for? I can't say: if string.empty then I have to use: if string = "" then which is ok, I just want to know what .empty is for.
10
by: arnuld | last post by:
this is from Steve Summit C notes: The empty pair of parentheses indicates that our main function accepts no arguments, that is, there isn't any information which needs to be passed in when the...
9
by: Two-Horned Unicorn | last post by:
The following code compiles and works as expected when compiled with gcc. /* empty-args.c */ #include <stdio.h> #define foo(x,y) puts("bar: x=\"" #x "\"; y=\"" #y "\"") #define bar(x) ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.