473,839 Members | 1,473 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Boost process and C

Hi,

Is there any group in the manner of the C++ Boost group that works on
the evolution of the C language? Or is there any group that performs an
equivalent function?

Thanks,
-vs

Apr 29 '06
335 11909
Ian Collins <ia******@hotma il.com> writes:
Keith Thompson wrote:
Ian Collins <ia******@hotma il.com> writes:
[snip]
I must be missing something, you have the same problem with pointers,
don't you?

If you see someFn( &x ), how do you know if someFn's prototype is

void someFn( int* ); or
void someFn( const int* );

without looking it up?

In new code, how can you call a function without knowing its prototype?

If you see someFn(x), you can be sure that someFn will not change the
value of x, even without understanding everything about someFn.

In a language with references, or with some sort of pass-by-reference
parameter mechanism, you can't be sure of that.

I see your point.

I'd still look at the prototype out of simple curiosity!


Sure, but it might not be obvious which of a dozen included headers
contains the prototype. Knowing that someFn can't modify x can be
useful in getting a quick partial understanding of the code in a
fairly quick look.

For example, suppose the code looks like this:

int x = 42;
/* do some stuff */
someFn(x);
/* do some other stuff */
printf("x = %d\n", x);

If you expect the printf to print "x = 42", and it instead prints
"x = -3" you can be sure that the problem is either before or after
the function call, not in the function itself.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
May 5 '06 #271
jacob navia wrote:
.... snip ...
This is not AT ALL my intention. The proposed changes do not affect
the efficency at all, and they are really optional in the sense
that the efficiency loss is only paid by people that use them. In
C++ you get your constructors/destructors whether you want it or
not. Operator overloading is a change that will affect only people
that use that feature. Nobody else has to pay for it.

The same thing for ALL other changes that are done in lcc-win32:

o overloaded functions: No efficiency lost since the compiler generates
the same machine code as before. This is just compile time changes.
o operator overloading: No efficiency lost for people that do not use
this feature. Some cycles (minimal) of extra cost are there for simple
implementations like the one in lcc-win32. An optimizing compiler
would have no trouble in eliminating it.
o Default arguments: No efficiency loss at all. This is just some
syntatic sugar.


Not so.

default arguments:
The compiler has to generate default parameter values. It can now
no longer detect omitted parameters during a call. One more source
of evil gotchas.

operator overloading:
Already exists in some places, since you can add floats, or
integers. Any further extension needs a complex set of automatic
cast rules and/or a set of implementing runtime routines, with
attendant source errors possible.

Overloaded functions:
The objections to default arguments apply. I could probably think
of more, including bloating the compiler proper.

If you examine the raw size of the C standard, you will find it is
roughly twice that of better designed languages already, to spell
out all the ifs, buts, and just in cases required by the baroque
syntax. The C++ standard eliminates much of this by simply
referring to the C standard. You would get further proposing
simplifications rather than complexities. C just grew, and the
standard shows it.

For example, a future standard could restrict 'precedence' to three
levels (e.g. logical, additive, and multiplicative) only, requiring
parentheses for any further control, yet allowing the actions of
the present silly system. The result would be clearer code without
necessarily breaking older code. It could deprecate such
obfuscative things as +=, without efficiency losses, since
optimizers can easily handle the longer phrases.

I can mention these possibilities, but I don't seriously expect
them to take place. And I will not run about weeping and whining
if the general readership does not enthusiasticall y rally behind
them.

--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell. org/google/>
Also see <http://www.safalra.com/special/googlegroupsrep ly/>
May 5 '06 #272
Keith Thompson wrote:
Ian Collins <ia******@hotma il.com> writes:
Keith Thompson wrote:

If you see someFn(x), you can be sure that someFn will not change the
value of x, even without understanding everything about someFn.

In a language with references, or with some sort of pass-by-reference
parameter mechanism, you can't be sure of that.


I see your point.

I'd still look at the prototype out of simple curiosity!

Sure, but it might not be obvious which of a dozen included headers
contains the prototype. Knowing that someFn can't modify x can be
useful in getting a quick partial understanding of the code in a
fairly quick look.

For example, suppose the code looks like this:

int x = 42;
/* do some stuff */
someFn(x);
/* do some other stuff */
printf("x = %d\n", x);

If you expect the printf to print "x = 42", and it instead prints
"x = -3" you can be sure that the problem is either before or after
the function call, not in the function itself.

All good and let me reiterate: I don't think references belong in C.

--
Ian Collins.
May 5 '06 #273
Ian Collins a écrit :
jacob navia wrote:
The operator overloading change do not affect efficiency at all. One of
the most "dreaded" features of C++ is the problem of avoiding
copy-constructors, constructors and destructors in apparently efficient
and simple statements like

a = *b;

Case 1:

int a;
int *b;

a = *b;

Show me where con/destructors are used.

Case 2:

struct x { int a, int b; };

struct x a;
struct x *b;

a = *b;

Show me where con/destructors are used.

You keep rambling on about this without any solid evidence.


Maybe. If b is a pointer to a class... That was case 3) in your list
that you left out. Why?

And what about an array of classes ???

Etc Etc. Please consult ANY C++ textbook and they will tell you many
ways to cleverly avoid that problem.
This is not AT ALL my intention. The proposed changes do not affect the
efficency at all, and they are really optional in the sense that the
efficiency loss is only paid by people that use them. In C++ you get
your constructors/destructors whether you want it or not. Operator
overloading is a change that will affect only people that use that
feature. Nobody else has to pay for it.

Twaddle.


This is a great argument.

"Twaddle".

I am impressed.
In case 2 above, both C and C++ compiler can generate the same code.

The same thing for ALL other changes that are done in lcc-win32:

o overloaded functions: No efficiency lost since the compiler generates
the same machine code as before. This is just compile time changes.


But opens up that other can of worms, name mangling and all the
incompatibiliti es that can introduce.


Only if you want the compiler to generate automatically the overloaded
names. If you provide the names, no mangling is done:

double fn1(double);
int fn2(long double,int);

double overloaded FN.fn1(double); // This will resolve to a call to fn1
int overloaded FN.fn2(long double); // Will resolve to a call to fn2

FN(2.3); --> will resolve into a call to fn1
FN(2.3L,1); --> will resolve into a call to fn2

No name mangling is done in this case. The overloaded function FN will
resolve to a call of fn1 in one case, fn2 in another case.
May 5 '06 #274
CBFalconer a écrit :
jacob navia wrote:

... snip ...
This is not AT ALL my intention. The proposed changes do not affect
the efficency at all, and they are really optional in the sense
that the efficiency loss is only paid by people that use them. In
C++ you get your constructors/destructors whether you want it or
not. Operator overloading is a change that will affect only people
that use that feature. Nobody else has to pay for it.

The same thing for ALL other changes that are done in lcc-win32:

o overloaded functions: No efficiency lost since the compiler generates
the same machine code as before. This is just compile time changes.
o operator overloading: No efficiency lost for people that do not use
this feature. Some cycles (minimal) of extra cost are there for simple
implementations like the one in lcc-win32. An optimizing compiler
would have no trouble in eliminating it.
o Default arguments: No efficiency loss at all. This is just some
syntatic sugar.

Not so.

default arguments:
The compiler has to generate default parameter values. It can now
no longer detect omitted parameters during a call. One more source
of evil gotchas.


No. Only functions with a prototype specifying default arguments can
have them. All other functions stay exactly the same.

Required arguments must come first in the call, and all optional
arguments come later. The compiler generates them from the prototype of
the function. This reduces the memory footprint for many functions.

Not RAM of course. Human memory, that is far more precious. Can't buy a
Gig of human memory at the next store to accomodate functions with 8 or
even 10 arguments!

operator overloading:
Already exists in some places, since you can add floats, or
integers. Any further extension needs a complex set of automatic
cast rules and/or a set of implementing runtime routines, with
attendant source errors possible.

Yes, and they are possible even now with the overloading of
int/floats/doubles/complex additions :-)
Overloaded functions:
The objections to default arguments apply. I could probably think
of more, including bloating the compiler proper.


The whole module for operator overloading and overloaded functions is
1723 lines of C including comments and lines with just an opening brace.

May 5 '06 #275
On Sat, 06 May 2006 00:48:45 +0200, in comp.lang.c , jacob navia
<ja***@jacob.re mcomp.fr> wrote:
Maybe. If b is a pointer to a class... That was case 3) in your list
that you left out. Why?
I'll take a wild guess - because C doesn't have classes?
And what about an array of classes ???
What, some sort of school assembly?
Etc Etc. Please consult ANY C++ textbook and they will tell you many
ways to cleverly avoid that problem.


What, *any* c++ text book? Hmm, I checked in "Learn Visual C++ in 21
days" and it barely mentioned classes...
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
May 5 '06 #276
CBFalconer <cb********@yah oo.com> writes:
[...]
For example, a future standard could restrict 'precedence' to three
levels (e.g. logical, additive, and multiplicative) only, requiring
parentheses for any further control, yet allowing the actions of
the present silly system. The result would be clearer code without
necessarily breaking older code.
You'd need at least four level, unless you want to require
x = y + z;
to be written as
x = (y + z);

But if you did reduce the number of precedence level, an automatic
tool could translate existing C to add newly required parentheses.
It could deprecate such
obfuscative things as +=, without efficiency losses, since
optimizers can easily handle the longer phrases.


<OPINION>LHS += RHS can be much clearer than LHS = LHS + RHS if LHS is
a complex expression</OPINION> -- and it's not equivalent if LHS has
side effects. (The counterargument is that, in cases where it
matters, you should write simpler code.)

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
May 5 '06 #277
jacob navia wrote:
Ian Collins a écrit :
jacob navia wrote:
The operator overloading change do not affect efficiency at all. One of
Case 1:

int a;
int *b;

a = *b;

Show me where con/destructors are used.

Case 2:

struct x { int a, int b; };

struct x a;
struct x *b;

a = *b;

Show me where con/destructors are used.

You keep rambling on about this without any solid evidence.


Maybe. If b is a pointer to a class... That was case 3) in your list
that you left out. Why?

Sorry but you are digging yourself into a hole. Ignoring the face that
C doesn't have classes, in C++ there is one difference between a struct
and a class - the default access. I could have written

Case 3:

class x { public: int a, int b; };

x a;
x *b;

a = *b;

But it isn't C and it adds nothing to the argument.

I say again, show me an example of con/destructor use in any of the above.
And what about an array of classes ???
What about one?
Etc Etc. Please consult ANY C++ textbook and they will tell you many
ways to cleverly avoid that problem.
This is not AT ALL my intention. The proposed changes do not affect the
efficency at all, and they are really optional in the sense that the
efficiency loss is only paid by people that use them. In C++ you get
your constructors/destructors whether you want it or not. Operator
overloading is a change that will affect only people that use that
feature. Nobody else has to pay for it.


Twaddle.


This is a great argument.

"Twaddle".

I am impressed.

Thank you, it was the most concise summary I could use without being rude :)
In case 2 above, both C and C++ compiler can generate the same code.
You didn't address the body of the argument, the line above.
The same thing for ALL other changes that are done in lcc-win32:

o overloaded functions: No efficiency lost since the compiler generates
the same machine code as before. This is just compile time changes.

But opens up that other can of worms, name mangling and all the
incompatibiliti es that can introduce.


Only if you want the compiler to generate automatically the overloaded
names. If you provide the names, no mangling is done:

double fn1(double);
int fn2(long double,int);

double overloaded FN.fn1(double); // This will resolve to a call to fn1
int overloaded FN.fn2(long double); // Will resolve to a call to fn2

FN(2.3); --> will resolve into a call to fn1
FN(2.3L,1); --> will resolve into a call to fn2

No name mangling is done in this case. The overloaded function FN will
resolve to a call of fn1 in one case, fn2 in another case.

Maybe not, but it's dead ugly and not recognisable C syntax. It's
introducing more complexity into the language.

--
Ian Collins.
May 5 '06 #278
Robert Latest wrote:
On 2006-05-04, we******@gmail. com <we******@gmail .com> wrote:
I think the point is that there are *many* such application. In fact I
would be suspicious of anyone who claimed to be an experienced
programmer who hasn't *written* one of these.
...and I would be suspcious of anyone who claimed to be an
experienced programmer who can't write the necessary routines
from scratch in less time than it takes to download, install, and
understand a dedicated string library. In fact I want to see a
single experienced programmer who hasn't written his own little
string library at some point in his career -- be it as a
homework assignment or just to kill time on a rainy weekend.


Can you write 102 well tested functions that are aliasing safe, support
write protection, have a performance advantage over comparable straight
C across the board on multiple platforms, in portable C, immune to
buffer overflows and size overflowing in less than an hour? That I
would like to see.

You also make the mistake of thinking experienced programmers are C
programmers. C (and C++) is the only language where someone would want
to *write* a string library. No other language needs it. And of
course, the fact the many C programmers might be writing string
libraries doesn't seemed to have affected the number of buffer overflow
flaws that are commonly shipped in applications written in C.
All these points are moot anyway -- it is very likely that the
people manipulating millions of tiny string needs a completely
different library than the huge-document-in-memory crowd. For
obvious reason, there is no one-size-fits-all solution.


Right -- Bstrlib is sometimes less than optimal for some instances of
those cases (though it is *always* safer and easier), and is really
only universally targetted at every single other case.

--
Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/

May 6 '06 #279
we******@gmail. com wrote:
Robert Latest wrote:
On 2006-05-04, we******@gmail. com <we******@gmail .com> wrote:
I think the point is that there are *many* such application. In fact I
would be suspicious of anyone who claimed to be an experienced
programmer who hasn't *written* one of these.


...and I would be suspcious of anyone who claimed to be an
experienced programmer who can't write the necessary routines
from scratch in less time than it takes to download, install, and
understand a dedicated string library. In fact I want to see a
single experienced programmer who hasn't written his own little
string library at some point in his career -- be it as a
homework assignment or just to kill time on a rainy weekend.

Can you write 102 well tested functions that are aliasing safe, support
write protection, have a performance advantage over comparable straight
C across the board on multiple platforms, in portable C, immune to
buffer overflows and size overflowing in less than an hour? That I
would like to see.

You also make the mistake of thinking experienced programmers are C
programmers. C (and C++) is the only language where someone would want
to *write* a string library. No other language needs it. And of
course, the fact the many C programmers might be writing string
libraries doesn't seemed to have affected the number of buffer overflow
flaws that are commonly shipped in applications written in C.

That's one of the things that hurts C, think how much more productive
those programmers would be if they didn't have to write their own string
library.

--
Ian Collins.
May 6 '06 #280

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

Similar topics

65
5406
by: perseus | last post by:
I think that everyone who told me that my question is irrelevant, in particular Mr. David White, is being absolutely ridiculous. Obviously, most of you up here behave like the owners of the C++ language. A C++ interface installation IS ABOUT THE C++ LANGUAGE! The language does not possess the ability to handle even simple file directory manipulation. Those wise people that created it did not take care of it. So, BOOST is a portable...
205
10760
by: Jeremy Siek | last post by:
CALL FOR PAPERS/PARTICIPATION C++, Boost, and the Future of C++ Libraries Workshop at OOPSLA October 24-28, 2004 Vancouver, British Columbia, Canada http://tinyurl.com/4n5pf Submissions
17
1902
by: Howard Gardner | last post by:
/* If I am using boost, then how should I write this program? As it sits, this program is using SFINAE to determine whether or not a type supports particular syntax. I suspect that there is functionality in boost to do this. I have found mpl::has_xxx, which I suspect of being part of the solution. I've also found type_traits::has_nothrow_constructor
2
6636
by: smith4894 | last post by:
{ not sure you're aware of that but there are the newsgroups for all major operating systems. you might want to try asking in the forum 'comp.os.linux.development.apps', since memory-mapped files are not a language-supported structure, they are platform-specific. -mod } I'm trying to use boost serialization to serialize/deserialize data to and from a mmap'd file. I have my own ostream/istream classes that essentially read/write bytes...
5
2400
by: linyanhung | last post by:
I used a boost multi thread in VS 2005 on a Duo Core PC, and made a two thread process. The code is something like this: #include <boost/thread/thread.hpp> void fun1() { //do something
8
6214
by: Matt England | last post by:
My team currently using Boost Threads, but we are considering switching to ZThreads. (We seek cross-platform, C++ multithreading capabilities in an external library.) ZThread(s): http://zthread.sourceforge.net/ http://www.inf.uni-konstanz.de/dbis/members/vinnik/zsim/doc/ Can anyone share their ZThreads experience, either good, bad, or
2
2417
by: ironpingwin | last post by:
Hi! I'd like to make few threads which will run in the same time in C++. I try to use boost library v 1.34.1 (it can't be newest, because I compile on remote machine, which is not administrated by me). In this version there isn't detach() function. How to run functions from two different class in the same time?
13
4541
by: brad | last post by:
Still learning C++. I'm writing some regex using boost. It works great. Only thing is... this code seems slow to me compared to equivelent Perl and Python. I'm sure I'm doing something incorrect. Any tips? #include <boost/regex.hpp> #include <iostream> // g++ numbers.cpp -o numbers -I/usr/local/include/boost-1_35 /usr/local/lib/libboost_regex-gcc41-mt-s.a // g++ numbers.cpp -o numbers.exe
5
3596
by: ameyav | last post by:
Hi All, I am converting some C code into C++ code. The objective is to improve throughput. I have some code written in C which serially parses through a list of files, opens each one of them, processes the data and closes the file. All the files are processed one by one. The obvious performance bottleneck that i could think of is the wasted cpu cycles for file i/o. *My solution* was to spawn multiple threads to do the file i/o. For...
0
9697
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
10906
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
10585
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
10647
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
10292
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
9426
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7017
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
5866
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4482
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.