473,915 Members | 3,885 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Making C better (by borrowing from C++)

I know that this topic may inflame the "C language Taleban", but is
there any prospect of some of the neat features of C++ getting
incorporated in C? No I am not talking out the OO stuff. I am talking
about the non-OO stuff, that seems to be handled much more elegantly in
C++, as compared to C. For example new & delete, references, consts,
declaring variables just before use etc.

I am asking this question with a vested interest. I would really like
to use these features in my C programs.

Masood

Nov 14 '05 #1
85 3329
ma**********@ly cos.com wrote:

I know that this topic may inflame the "C language Taleban", but is
there any prospect of some of the neat features of C++ getting
incorporated in C? No I am not talking out the OO stuff. I am talking
about the non-OO stuff, that seems to be handled much more elegantly in
C++, as compared to C. For example new & delete,
Pointless without adding constructors and destructors too, which
might be further than the C community wants to go.
references,
An excellent way to confuse people still further wrt pointers.
consts,
Got them.
declaring variables just before use etc.


Got them in C99.
Nov 14 '05 #2
On 12 Feb 2005 05:36:00 -0800, ma**********@ly cos.com
<ma**********@l ycos.com> wrote:
I know that this topic may inflame the "C language Taleban", but is
there any prospect of some of the neat features of C++ getting
incorporated in C? No I am not talking out the OO stuff. I am talking
about the non-OO stuff, that seems to be handled much more elegantly in
C++, as compared to C. For example new & delete, references, consts,
declaring variables just before use etc.
Note that quite a few features have already made it back -- void,
declaring variables in the middle of code, single-line comments for
instance.

There is no point to new and delete without constructors and
destructors, and to have those you'd need to introduce classes (and then
you'd have "C with classes", which was how C++ started out.

References are nice in some ways, but are really just syntactic sugar
round pointers, and can be even more confusing (especially when it isn't
obvious that a parameter may change).

Proper named and typed constants would indeed be useful, C's version of
const is a compiler convenience, and I can see those making it into C at
some point, but most of the other features depend on classes.

I can think of other things I'd like more. A typeof operator, for
example, and to have known-width arithmetic types build into the
language instead of via a header file (which isn't guaranteed to even
provide them). I'd really like a portable way of having enum values as
strings so that I could use strtoenum() for input and a printf
descriptor to output an enum as its named values. I'd like those in C++
as well...
I am asking this question with a vested interest. I would really like
to use these features in my C programs.


Why not use C++ instead, if that's what you like? That's what I do, I
use C++ for things where I want high-level features and I use C for
portability (adding C++ features to C won't make them portable, we're
over 5 years after the last C standard came out and I still can't safely
assume that any of the features introduced are portable (there seems to
be possibly one compiler and library which is fully C99 compliant) and
some systems don't even fully implement the standard from 10 years
before that).

Chris C
Nov 14 '05 #3
Chris Croughton wrote:
.... snip ...
References are nice in some ways, but are really just syntactic
sugar round pointers, and can be even more confusing (especially
when it isn't obvious that a parameter may change).


I used to miss them sorely, but eventually got used to the idea
that the caller can tell when it is exposing its internal data to
outside influence without examining the header of the called
function. Of course the cost is that pointers are not under
control, and that proper verification is impossible to all
practical purposes.

--
"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

Nov 14 '05 #4
ma**********@ly cos.com wrote:
I know that this topic may inflame the "C language Taleban", but is
there any prospect of some of the neat features of C++ getting
incorporated in C? No I am not talking out the OO stuff. I am talking
about the non-OO stuff, that seems to be handled much more elegantly in
C++, as compared to C. For example new & delete, references, consts,
declaring variables just before use etc.

I am asking this question with a vested interest. I would really like
to use these features in my C programs.

Masood


The lcc-win32 compiler adds some features of C++ like:

o operator overloading
o default arguments to functions
o references

Declaring variables just vefore use is part of the
C99 standard

http://www.cs.virginia.edu/~lcc-win32
Nov 14 '05 #5
On 12 Feb 2005 05:36:00 -0800, in comp.lang.c , ma**********@ly cos.com
wrote:
I know that this topic may inflame the "C language Taleban", but is
there any prospect of some of the neat features of C++ getting
incorporated in C?
Some C++ features made it into C99. Others don't make sense in C, such as
new, delete, reference variables and so forth. For your info consts have
been in C for decades, and declare-before-use is in C99.
I am asking this question with a vested interest. I would really like
to use these features in my C programs.


Then use C++

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt >
Nov 14 '05 #6
On 12 Feb 2005 05:36:00 -0800, in comp.lang.c , ma**********@ly cos.com
wrote:
I know that this topic may inflame the "C language Taleban", but is
there any prospect of some of the neat features of C++ getting
incorporated in C?
Some C++ features made it into C99. Others don't make sense in C, such as
new, delete, reference variables and so forth. For your info consts have
been in C for decades, and declare-before-use is in C99.
I am asking this question with a vested interest. I would really like
to use these features in my C programs.


Then use C++

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt >

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 14 '05 #7
In article <11************ **********@l41g 2000cwc.googleg roups.com>,
ma**********@ly cos.com wrote:
I know that this topic may inflame the "C language Taleban"


Not very clever starting with an insult like that, if you want to be
taken serious?
Nov 14 '05 #8
On Sat, 12 Feb 2005 18:47:44 GMT, CBFalconer
<cb********@yah oo.com> wrote:
Chris Croughton wrote:

... snip ...

References are nice in some ways, but are really just syntactic
sugar round pointers, and can be even more confusing (especially
when it isn't obvious that a parameter may change).


I used to miss them sorely, but eventually got used to the idea
that the caller can tell when it is exposing its internal data to
outside influence without examining the header of the called
function. Of course the cost is that pointers are not under
control, and that proper verification is impossible to all
practical purposes.


When I'm writing C++ I use reference parameters, because I like the
cleanness of the call. However I've been bitten by them several times,
so it's a kind of "love-hate" relationship, I can see good reasons both
for using them and for avoiding them. The thing I do like and miss from
C++ (which C99 has now but none of the compilers for which I have to
write portable C code supports) is declaring 'local' loop variables:

for (int i = 0; i < n; ++i)
...

I'm always forgetting that C89 doesn't have that...

Chris C
Nov 14 '05 #9
ma**********@ly cos.com writes:
I know that this topic may inflame the "C language Taleban", but is
there any prospect of some of the neat features of C++ getting
incorporated in C? No I am not talking out the OO stuff. I am talking
about the non-OO stuff, that seems to be handled much more elegantly in
C++, as compared to C. For example new & delete, references, consts,
declaring variables just before use etc.


As others have pointed out, some of these things are already in C99.
And I believe that prototypes were first introduced in (pre-standard)
C++ and added to C with the 1989 ANSI standard. I don't think there's
any great resistance to the idea of adding some C++ features to C *if*
they fit into the C language.

On the other hand, if you want C++ features that C doesn't have, the
easiest way to get them is to use C++.

Incidentally, calling people "Taleban" is a really bad way to
influence them.

--
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.
Nov 14 '05 #10

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

Similar topics

204
5162
by: Masood | last post by:
I know that this topic may inflame the "C language Taleban", but is there any prospect of some of the neat features of C++ getting incorporated in C? No I am not talking out the OO stuff. I am talking about the non-OO stuff, that seems to be handled much more elegantly in C++, as compared to C. For example new & delete, references, consts, declaring variables just before use etc. I am asking this question with a vested interest. I...
0
10039
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
9883
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,...
1
11069
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
10543
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
9734
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...
1
8102
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
6149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4779
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
2
4346
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.