473,854 Members | 1,638 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 11964
Ian Collins a écrit :
jacob navia wrote:
Ian Collins a écrit :

jacob navia wrote:
Why should I swallow that big fat language?

I just want a few specific features that are part of many programming
languages , from fortran to visual basic...

Operator overloading is a well known technique, no need to swallow
all C++ to get it. Thank you
If you want a chop do you eat the entire pig? Just use the bits you
want and ignore the rest.

This is not possible. For some operators, C++ decides that they
need to be defined only within a class, and there you are. You are
forced to define classes, constructors, destructors, copy constructors,
and all the stuff.


That's because they only make sense in the context of an object, you
have to (for example) add something to something else. The are no
restrictions on function overloading. You could use a simple struct.


well, that's my point. In C++ I czan't avoid classes, constructors,
destructors and the whole complexity, even if I want to use a simple
thing like

typef struct __int128 { int32_t part1,part2,par t3,part4} INT128;
INT128 operator+(INT12 8 *a,INT128 *b)
{
....
}

INT128 operator+(INT12 8 *a,long long b)
{
....
}
Besides, there are things that the C++ operator overloading
implementatio n gets wrong:

1) There is no overloading possible for higher dimensional arrays

array[2][3] is just impossible using overloaded operators.

Indeed.


It should be possible to do, I mean higher dimensional arrays are not
something new...
2) There is no way to distinguish between assignment and reading when
accessing an array. This is specially important when you want to
implement read only data areas.

There is a very simple technique known as proxy objects to solve this
problem, but that's a bit to OT for this forum.


No, it is not OT because that confirms what I said:

You can't just take a small piece. YOU GET THE HOLE PIG AT EACH SERVING!

:-)
jacob
Apr 30 '06 #41

jacob navia wrote:
<snip>

If there is no clear place where the evolution of C can be
discussed, then it won't be, and C will not evolve. <snip>
Still, C has a big potential of growth with some minor additions like
operator overloading, something that is accepted by more conservative
languages like fortran for instance.


Operator overloading is, IMHO, a really, really bad idea. I've only
been coding C for just under a year, and 11 months ago I was really
bent out of shape that I couldn't write:
struct foo A,B,C;
A = B + C;
but I'm really glad now that I can't, and I would hate to see operater
overloading be expanded in C. Operator overloading in C is the root
cause of a very large number of bugs already. How many bugs are a
result of "3+4" being different that "3.0 + 4.0"? Those bugs would
have been avoided had the programmer been required to type
"int_add(3, 4)" or "float_add(3,4) ". Now, I'm not arguing that the '+'
symbol be dropped for arithmetic on basic numeric types, but expanding
the language to allow '+' as an infix operator on user-defined structs
is just asking for trouble. The only gain is (arguably) cleaner code,
but quite frankly "A = foo_add(B,C)" is more informative than "A =
B+C" and less prone to error.

Apr 30 '06 #42
jacob navia wrote:

well, that's my point. In C++ I czan't avoid classes, constructors,
destructors and the whole complexity, even if I want to use a simple
thing like

typef struct __int128 { int32_t part1,part2,par t3,part4} INT128;
INT128 operator+(INT12 8 *a,INT128 *b)
{
....
}

INT128 operator+(INT12 8 *a,long long b)
{
....
}

struct int128_t { int32_t part1,part2,par t3,part4 };

Other than that correction and the operator bodies, you've written all
you have to write.
2) There is no way to distinguish between assignment and reading when
accessing an array. This is specially important when you want to
implement read only data areas.


There is a very simple technique known as proxy objects to solve this
problem, but that's a bit to OT for this forum.


No, it is not OT because that confirms what I said:

You can't just take a small piece. YOU GET THE HOLE PIG AT EACH SERVING!

No, how would you differentiate between read and write to an array in C?

If you want the extra fat, you pay for it, if you don't, you don't.

It's a popular misconception that C++ has to be more complex than C. It
doesn't.

--
Ian Collins.
Apr 30 '06 #43
Bill Pursell a écrit :
jacob navia wrote:
<snip>

Still, C has a big potential of growth with some minor additions like
operator overloading, something that is accepted by more conservative
languages like fortran for instance.
Operator overloading is, IMHO, a really, really bad idea. I've only
been coding C for just under a year, and 11 months ago I was really
bent out of shape that I couldn't write:
struct foo A,B,C;
A = B + C;
but I'm really glad now that I can't, and I would hate to see operater
overloading be expanded in C. Operator overloading in C is the root
cause of a very large number of bugs already. How many bugs are a
result of "3+4" being different that "3.0 + 4.0"?


Sorry but 3+4 is identical to 3.0+4.0 : SEVEN in BOTH cases, only the
representtion of the number changes.

Maybe you meant 3/4 and 3.0/4.0 ???
Those bugs would
have been avoided had the programmer been required to type
"int_add(3, 4)" or "float_add(3,4) ".
Aaaahhh what an easy syntax...

What would you do with

z = sqrt((a+b)/(b-d) +0.5*d/(a*d-b*d);

???????

Yes, you have to COMPILE THEM by hand producing this incredible GIBBERISH!

tmp1=float_add( a,b);
tmp2=float_sub( b,d);
tmp3=float_div( tmp1,tmp2);
tmp4=float_mul( 0.5,d);
tmp5=float_mul( a,d);
tmp6=float_mul( b,d);
tmp7=float_sub( tmp5,tmp6);
tmp8=float_div( tmp4,tmp7);
tmp9=float_add( tmp3,tmp8);
z=sqrt(tmp9);
IF you manage to compile that expression without making ANY MISTAKE.
That is MUCH MORE ERROR PRONE THAN

z = sqrt((a+b)/(b-d) +0.5*d/(a*d-b*d);
Besides there isn't a single maintenance programmer that can understand
that GIBBERISH without decompiling it (by hand) into
z = sqrt((a+b)/(b-d) +0.5*d/(a*d-b*d)
again!

And if you change the type of the data from float to long double you
have to edit all those function calls!

Now, I'm not arguing that the '+'
symbol be dropped for arithmetic on basic numeric types, but expanding
the language to allow '+' as an infix operator on user-defined structs
is just asking for trouble. The only gain is (arguably) cleaner code,
but quite frankly "A = foo_add(B,C)" is more informative than "A =
B+C" and less prone to error.

You are dreaming. LESS PRONE TO ERROR??????????
Apr 30 '06 #44
Ian Collins a écrit :

No, how would you differentiate between read and write to an array in C?


lcc-win32 proposes the [] operator for reading, and the []= for assignment

Apr 30 '06 #45
jacob navia wrote:
Ian Collins a écrit :

No, how would you differentiate between read and write to an array in C?


lcc-win32 proposes the [] operator for reading, and the []= for assignment

Fine, but how would you do it in standard C?

--
Ian Collins.
Apr 30 '06 #46
Bill Pursell wrote:
Now, I'm not arguing that the '+'
symbol be dropped for arithmetic on basic numeric types, but expanding
the language to allow '+' as an infix operator on user-defined structs
is just asking for trouble. The only gain is (arguably) cleaner code,
but quite frankly "A = foo_add(B,C)" is more informative than "A =
B+C" and less prone to error.

I think Jacob's example applies equally well to this case.

You end up with the same mess that Java has to put up with.

Operator overloading enables you to use a user defined type in the same
way as a built in type. Much more intuitive.

--
Ian Collins.
Apr 30 '06 #47
Chris Hills schrieb:
In article <4b************ *@individual.ne t>, Michael Mair
<Mi**********@i nvalid.invalid> writes
Chris Hills schrieb:
In article <4b************ *@individual.ne t>, Michael Mair
<Mi********* *@invalid.inval id> writes

Chris Hills schrieb:

>For embedded work most of the world uses MISRA-C. It is also what the
>tool vendors support.

Don't I know it...
Especiall y Japanese customers ask for MISRA compliance even in
generated code -- and, ideally, always all versions at once.

There are only 2 versions. You can not comply with both at once.
I know ;-)


In any event "compliance " is anything you want as there is no official
certification or compliance testing for MISRA-C. Just like most C
compilers claim to be "ANSI C" or "ISO C".


There are "MISRA checkers", though, and I remember having seen
the option to activate MISRA-C checks in some lint tool, probably
PCLint.

However there will be an example suite for MISRS-C2 by the end of the
year. It will not be exhaustive so I expect it to grow over the next
couple of years.
Thank you for the information.

Hopefully as MISRA-C3 is developed the example suite will be developed
with it and launched at the same time..


This sounds promising -- I only can recommend this course of action;
the time and money usually are well invested.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Apr 30 '06 #48

jacob navia wrote:
Bill Pursell a écrit :
jacob navia wrote:
<snip>

Still, C has a big potential of growth with some minor additions like
operator overloading, something that is accepted by more conservative
languages like fortran for instance.
Operator overloading is, IMHO, a really, really bad idea. I've only
been coding C for just under a year, and 11 months ago I was really
bent out of shape that I couldn't write:
struct foo A,B,C;
A = B + C;
but I'm really glad now that I can't, and I would hate to see operater
overloading be expanded in C. Operator overloading in C is the root
cause of a very large number of bugs already. How many bugs are a
result of "3+4" being different that "3.0 + 4.0"?


Sorry but 3+4 is identical to 3.0+4.0 : SEVEN in BOTH cases, only the
representtion of the number changes.


The representation is often significant, and my point is that
overloading the '+' operator obscures that detail from the programmer.

Maybe you meant 3/4 and 3.0/4.0 ???
No. I meant '+'.
Those bugs would
have been avoided had the programmer been required to type
"int_add(3, 4)" or "float_add(3,4) ".


Aaaahhh what an easy syntax...

What would you do with
z = sqrt((a+b)/(b-d) +0.5*d/(a*d-b*d);


As I said, I'm not suggesting that the basic arithmetic operators be
removed from the language, and this is an excellent example of their
utility. Can you come up with a similar example that doesn't rely on
fundamental types? I've never seen an object in any language that was
prone to this type of calculation, and certainly never seen a structure
in a C program to which this would apply. Any such calculation should
be performed by a function anyway, so rather than forcing the
maintenance programmer to parse:
z = sqrt((a+b)/(b-d) +0.5*d/(a*d-b*d);
that same programmer would have to parse:
z = determinant( A);
or the like.
Yes, you have to COMPILE THEM by hand producing this incredible GIBBERISH!

tmp1=float_add( a,b);
tmp2=float_sub( b,d);
tmp3=float_div( tmp1,tmp2);
tmp4=float_mul( 0.5,d);
tmp5=float_mul( a,d);
tmp6=float_mul( b,d);
tmp7=float_sub( tmp5,tmp6);
tmp8=float_div( tmp4,tmp7);
tmp9=float_add( tmp3,tmp8);
z=sqrt(tmp9);
Which would be implemented as an appropriately named function.

<snip> And if you change the type of the data from float to long double you
have to edit all those function calls!
And since you've encapsulated the computation in a function, you now
only have to change the definition of that one function. If you had
overloaded the operators, you would have to change the definition of
the overloaded function, so you've gained nothing.
Now, I'm not arguing that the '+'
symbol be dropped for arithmetic on basic numeric types, but expanding
the language to allow '+' as an infix operator on user-defined structs
is just asking for trouble. The only gain is (arguably) cleaner code,
but quite frankly "A = foo_add(B,C)" is more informative than "A =
B+C" and less prone to error.

You are dreaming. LESS PRONE TO ERROR??????????


Yes. Less prone to error, because things are explicit. You choose to
code in a language because you are making a decision about what aspects
of the system you want hidden, and what aspects you want explicit. In
C (in my opinion), this is precisely the type of detail that should not
be hidden. Function overloading is really nice, it's very handy, and
most of the time I really like it. I just don't think it belongs in C.
And I'm far more likely to change my mind if you don't shout. :)

Apr 30 '06 #49

Ian Collins wrote:
Bill Pursell wrote:
Now, I'm not arguing that the '+'
symbol be dropped for arithmetic on basic numeric types, but expanding
the language to allow '+' as an infix operator on user-defined structs
is just asking for trouble. The only gain is (arguably) cleaner code,
but quite frankly "A = foo_add(B,C)" is more informative than "A =
B+C" and less prone to error.
I think Jacob's example applies equally well to this case.

You end up with the same mess that Java has to put up with.


I'm not familiar with Java.
Operator overloading enables you to use a user defined type in the same
way as a built in type. Much more intuitive.


I'm not convinced that it provides added intuition. As I pointed out
in my response to Jacob, any sufficiently complex computation should
have a function to perform it. If foo represents a mathematical object
and we want to perform some computation on it, then whether you have
operator overloading or not, you end up with the code:
compute_contour _integral (A, f);
Having the overloading might encourage someone to write the code
in-line rather than make a function call, leading to more diffictult
code, not less.

Apr 30 '06 #50

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

Similar topics

65
5408
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
10771
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
1906
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
6216
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
4542
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
9752
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
11031
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...
1
10763
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
10371
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...
1
7918
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7082
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
5750
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
5942
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4563
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.