473,667 Members | 2,548 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(,fals e,); //chair, bed, no table, no running water
Room toilet(,false,f alse); //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 3275
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(,fals e,); //chair, bed, no table, no running
water
Room toilet(,false,f alse); //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,c har,"Farewell") ;

-X
Jul 19 '05 #4
In article <bl**********@n ews4.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**********@n ews1.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.l earn.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(,fals e,); //chair, bed, no table, no running water
Room toilet(,false,f alse); //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

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

Similar topics

1
5025
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 double-checked the path to my error log. It is in /var/www/logs/php_error_log Thanks. :) -Wayne Stevenson
3
8888
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 a empty value instead of returning the browser type. Here is the line which i am using in my code and from manual: <?php echo $_SERVER; ?>
25
9116
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 <iostream> #include <string> using namespace std; #define B(X, Y) Y
23
4074
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 <foo/>) From XHTML specification:
0
1337
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: "Arguments" property is always an empty string (the same happens to "Filename" property). Could it be a permission problem? My pc is running Windows XP SP1 and I
12
17098
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. This is okay in some cases (such as <tbody>), but problematic for other tags (such as <option>). Some tags (td, th, ...) do not produce warnings when they are empty.
14
2335
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
6903
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 function is called. i think, an "empty pair" of parenthesis means a function can take unlimited number of arguments
9
7680
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) puts("foo: x=\"" #x "\"")
0
8363
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8883
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8787
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8561
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8645
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4200
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.