473,839 Members | 1,538 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
Bill Pursell wrote:
Ian Collins wrote: I'm not familiar with Java.
It lack operator overloading.
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.

The classic example was a complex type, but this in now part of C99.
The example of a 128 bit int type Jacob posted earlier is one good
example of an numeric user type. Others I have used often (in C++) are
time types (with a seconds and nanoseconds part) and pointers to
circular buffers.

User defined big int types are very handy for porting code between
systems that do and don't support them, for example int64_t. You can
use a typedef to select between native of user type and any code that
manipulates them doesn't care whether int64_t is a POD or a user type.

--
Ian Collins.
Apr 30 '06 #51
Bill Pursell a écrit :
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.

lcc-win32 offers qfloats, 350 bit floating pint. Those numbers are easy
to use. To change your precision from double (64 bits) to qfloat (350
bits) you just #define double qfloat and do not have to change anything
in the code. That's the point of all this stuff. Numerical formulae and
computations remain the same even if the precision of the computations
goes up.

Besides, making a function for every moderately complex statement is an
overkill. The equation above is just one line, but in any serious
mathematical software there are literally hundredths of them.

Of course you can misuse operator overloading, as you can misuse anything.

For instance the famous overloading of the "+" operator for character
strings that C++ promotes is WRONG (this is not "shouting" is just
emphasis!)

Why?

Because + is commutative in maths: a+b is equal to b+a, and that is not
the case with a+b when a and b are strings:

"Hello" + " World" is different from
"World" + "Hello"

Ingeneral operator overloading is good with numbers because it allows
people to create their own types of numbers.
Yes, you have to COMPILE THEM by hand producing this incredible GIBBERISH!

tmp1=float_ad d(a,b);
tmp2=float_su b(b,d);
tmp3=float_di v(tmp1,tmp2);
tmp4=float_mu l(0.5,d);
tmp5=float_mu l(a,d);
tmp6=float_mu l(b,d);
tmp7=float_su b(tmp5,tmp6);
tmp8=float_di v(tmp4,tmp7);
tmp9=float_ad d(tmp3,tmp8);
z=sqrt(tmp9 );

Which would be implemented as an appropriately named function.


But that function would be a lot of GIBBERISH and completely unmaintenable.

The gibberish would be encapsulated but it would be a pain to maintain
anyway!
Apr 30 '06 #52
On 2006-04-30, Ian Collins <ia******@hotma il.com> 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.

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


Some of the side-effects are less agreeable though.

You end up needing something like C++ references, in order to provide a
way of overloading the operators in expressions like a = b = c.

In expressions like a = b + c, where a, b and c are all large instances,
you really want to copy the result of b + c directly into a. What you
end up with is operator+(b, c) returning an instance, and then
operator=(a, b) copying the instance into a. Compilers have clever ways
to work around this, while still having to call the constructor for the
temporary b + c and a's assignment operator (or copy ctor if it's an
initialization) , as if it were doing add followed by copy, since those
could have arbitrary sideeffects.

Whether this nightmare is acceptable or not is a matter of opinion-- but
it strikes me as a whole new class of nightmare that C never had to deal
with before. Like anything, C has its strenths and weaknesses and one of
the strengths has always been the relative lack of nasty surprises.

Another thing about C is the fact that in general the cost of every
operation is fairly intuitively obvious in what you type. If you type an
expression with operators, you will get a bit of machine arithmetic. If
you need to call a function, you will see the function call. If you copy
a lot of data (rather than just one or two words) you will have to call
memcpy or friends (with the exception of struct instance assignment).
You lose this with operator overloading.

Builtin types and user-defined types are very different things in C, and
these are sensible lines along which to design a machine-oriented
language that runs on machines which have memory for data, and registers
and ALUs for operations on builtin types. In "higher-level" languages
which are further abstracted from the implementation, it's attractive to
remove this distinction-- Python for example achieves this well. But I'm
not convinced of the wisdom of the hybrid, C with operator overloading.
Apr 30 '06 #53
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**********@i nvalid.invalid> writes
Chris Hills schrieb:

In article <4b************ *@individual.ne t>, Michael Mair
<Mi******** **@invalid.inva lid> 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...
>Especial ly Japanese customers ask for MISRA compliance even in
>generate d 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.


There are many checkers. However, and this is the problem, there is no
official MISRA/MIRA certification or check on any of the tools that
claim to check MISRA-C.

So it is purely their interpretation of the MISRA rules and how to test
them. That said 99% of the tool vendors are doing it in good faith. SO
there is no write or wrong tool so far. Though a couple have come close
to letting their marketing team too much rope :-)

You may need to specify where you want MISRA-C compliance which tool
should be used to test. You don't want an argument because you use one
tool and the client uses a different one.

Whilst this is not an ideal situation it is improving the general level
of things a lot. Some of the feedback from tool vendors is helping to
remove some of the ambiguity in some rules.

Future releases of MISRA-C should improve and standardise things over
time.
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.


Distribution was discussed last week. I think the suite should be
widely available for both tool vendors and users. We looked at a check
summed distribution so that you know you have a valid (and not edited)
suite.
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.


Time and money.... :-)

MISRA C++ has taken this route and we will see how they get on.
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys. org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Apr 30 '06 #54
Ben C wrote:
Another thing about C is the fact that in general the cost of every
operation is fairly intuitively obvious in what you type. If you type an
expression with operators, you will get a bit of machine arithmetic. If
you need to call a function, you will see the function call. If you copy
a lot of data (rather than just one or two words) you will have to call
memcpy or friends (with the exception of struct instance assignment).
You lose this with operator overloading.

Builtin types and user-defined types are very different things in C, and
these are sensible lines along which to design a machine-oriented
language that runs on machines which have memory for data, and registers
and ALUs for operations on builtin types. In "higher-level" languages
which are further abstracted from the implementation, it's attractive to
remove this distinction-- Python for example achieves this well. But I'm
not convinced of the wisdom of the hybrid, C with operator overloading.


I agree 100% that operator overloading is inappropriate for C. If you
want it, use C++.

I was responding to the more abstract conjecture that operator
overloading is a bad thing per se, which I believe to be untrue. It
would be a bad thing in C for the reasons you mention, but when used
elsewhere it leads to cleaner, more maintainable code.

--
Ian Collins.
Apr 30 '06 #55
Ben C a écrit :
Some of the side-effects are less agreeable though.

You end up needing something like C++ references, in order to provide a
way of overloading the operators in expressions like a = b = c.

In expressions like a = b + c, where a, b and c are all large instances,
you really want to copy the result of b + c directly into a. What you
end up with is operator+(b, c) returning an instance, and then
operator=(a, b) copying the instance into a. Compilers have clever ways
to work around this, while still having to call the constructor for the
temporary b + c and a's assignment operator (or copy ctor if it's an
initialization) , as if it were doing add followed by copy, since those
could have arbitrary sideeffects.

Since there are no constructors neither copy constructors in C the
optimization is muc h simpler than in C++.

True, we need the references, what is a good improvement anyway.

Whether this nightmare is acceptable or not is a matter of opinion-- but
it strikes me as a whole new class of nightmare that C never had to deal
with before. Like anything, C has its strenths and weaknesses and one of
the strengths has always been the relative lack of nasty surprises.

No surprise here either, if you do not use this feature. Contrary to C++
all this is completely optional. The behavior of old programs and of
programs written not using this features is not affected.
Another thing about C is the fact that in general the cost of every
operation is fairly intuitively obvious in what you type. If you type an
expression with operators, you will get a bit of machine arithmetic. If
you need to call a function, you will see the function call. If you copy
a lot of data (rather than just one or two words) you will have to call
memcpy or friends (with the exception of struct instance assignment).
You lose this with operator overloading.

Sorry but in a 32 bit machine:
unsigned long long a,b,c;

...

a = b/c;

is very likely to invoke a function call...

Many operations are implemented as function calls behind the scenes,
specially in 16 bit compilers that need to implement 64 bit types.

Builtin types and user-defined types are very different things in C, and
these are sensible lines along which to design a machine-oriented
language that runs on machines which have memory for data, and registers
and ALUs for operations on builtin types.
Truncated addition is present in many CPUs since several years but since
C has not operator overloading nobody can do that in C.

In truncated addition

char a=200,b=200,c;

c = a+b;

c is now 255. The highest value acceptable. No wrap around.

This has been available in ALL PCs since years with the MMX instruction
set. But nobody can use them because since operators can't be
overloaded, this would need

c = truncated_addit ion(a,b);
In "higher-level" languages
which are further abstracted from the implementation, it's attractive to
remove this distinction-- Python for example achieves this well. But I'm
not convinced of the wisdom of the hybrid, C with operator overloading.


I am certain that the conservative option just puts brakes to the
development of the language
Apr 30 '06 #56
About libclc - how is that doing? It seems to have just dried up
without notice. Also, I seem

If a C programmer is writing a reasonably large program these days,
what are the first libraries that are commonly used for collections of
data structures, better strings, etc?

Apr 30 '06 #57
About libclc - how is that doing? It seems to have just dried up
without notice.

If a C programmer is writing a reasonably large program these days,
what are the first libraries that are commonly used for collections of
data structures, better strings, etc?

Apr 30 '06 #58
ex************* *@gmail.com a écrit :
About libclc - how is that doing? It seems to have just dried up
without notice.

If a C programmer is writing a reasonably large program these days,
what are the first libraries that are commonly used for collections of
data structures, better strings, etc?


Nowhere. Since the C standard comitee refuses to improve the language,
there are a lot of libraries but all of them incompatible.

Basically, the opinion here is that data structures are too much of an
intellectual effort for C programmers... :-)
Apr 30 '06 #59

jacob navia wrote:
Bill Pursell a écrit :
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.


lcc-win32 offers qfloats, 350 bit floating pint. Those numbers are easy
to use. To change your precision from double (64 bits) to qfloat (350
bits) you just #define double qfloat and do not have to change anything
in the code. That's the point of all this stuff. Numerical formulae and
computations remain the same even if the precision of the computations
goes up.


If the 350 bit floating point type is a data structure that is known to
the compiler, it seems that it's not really a user defined type. In
other words, when you write the compiler to accept this data type, then
you're completely free to add semantics for operators as well. I
certainly don't think that's a bad thing. I welcome the complex data
type in C99.

I think my concern is that I've seen a lot of horribly written C++
code, and slightly less bad C, and it seems that allowing operator
overloading will just increase the amount of bad C code that's out
there.

Apr 30 '06 #60

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
9855
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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
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
5682
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
5866
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3132
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.