Making C better (by borrowing from C++)

S

santosh

Ben said:
Why? Both C89 and C99 were arrived at via a standards process.
Both were the current standard at one point.

Currently Standard C means ISO 9899:1999.

But I understand that this group accepts discussion on C as defined by
the current Standard, the previous Standard (including it's amendment)
and also "K&R" C for historical reasons.
 
J

James Kuyper

Masood said:
I know that this topic may inflame the "C language Taleban", but is

Let's see, what characteristics do the people I think you're referring
to share with the Taliban? Well, like the Taliban, they have definite
strong opinions about how some things should be done, and voice those
opinions publicly. They share this characteristic with most churches,
the police, the Better Business Bureau, most of the people who decide to
run for public office, and virtually anyone else who's adequately
qualified for a leadership position of any kind.

What characteristics don't they share with the Taliban? Well, most
importantly, they haven't killed anybody. They haven't tortured anybody.
They haven't physically mutilated anybody. They don't have any power
whatsoever to enforce their opinions on anyone else. They have no power
over anyone else except through words. In other words, they don't
possess a single one of the powers whose abuse by the Taliban justly
earned the Taliban a death sentence.

If the Taliban had restricted their activities to the same ones used by
the people you're calling the "C language Taliban", they'd be no more
than one more religious group among many others, trying to spread it's
own point of view by persuasion, not force, as is the right of every
human being.

I also believe that there's another difference, but I doubt it's one I
could get you to agree with: unlike religious groups, the people you
call the "C language Taliban" include many who are susceptible to
changing their minds when faced with with well reasoned argument based
upon citations from the standard. Also, unlike the believers, they do
not consider the standard to be divinely inspired; the very human and
occasionally fallible authors of the C standard are clearly recognized
as such by virtually everyone here. They also understand, better than
their detractors, the way in which historical accidents have trapped the
standard in certain ways, due to the practical necessity of maintaining
backwards compatibility.
 
J

James Kuyper

If I understand your question correctly, my answer is "no".

Are you saying that fighting with Jacob Navia is "quality"?

No, it's one method, among many, for trying to achieve quality control.
It achieves that goad by clearly tagging as such the low quality advice
he often provides.
 
K

Kenny McCormack

No, it's one method, among many, for trying to achieve quality control.
It achieves that goad by clearly tagging as such the low quality advice
he often provides.

Oh, the irony...
 
J

James Kuyper

jacob navia wrote:
....
That is ridiculous. I could also argue that RH exploits this group
commercially since the fact of him being the guru here promotes his book
and he earns money with it.

Let's compare. How many messages from Richard Heathfield even mention
his book, much less promote it? The only reason I was even aware of his
authorship was the fact that someone else mentioned it, and he responded.

How often have you resisted the temptation to mention lcc-win? I've seen
dozens, possibly hundreds of cases where you failed this temptation just
in the short time I've been closely monitoring this group.
 
J

jacob navia

James said:
No, it's one method, among many, for trying to achieve quality control.
It achieves that goad by clearly tagging as such the low quality advice
he often provides.

Even if you repeat that lie a thousand times it doesn't make
it true...

Bad quality means that I very often ANSWER the questions posed instead
of saying like many of the regulars

"go away"...

You do not cite any examples, but it is obvious that I have a different
view point than many here. That makes it for "bad advice" in your
opinion.

IN YOUR OPINION!
 
J

jacob navia

James said:
jacob navia wrote:
...

Let's compare. How many messages from Richard Heathfield even mention
his book, much less promote it? The only reason I was even aware of his
authorship was the fact that someone else mentioned it, and he responded.

How often have you resisted the temptation to mention lcc-win? I've seen
dozens, possibly hundreds of cases where you failed this temptation just
in the short time I've been closely monitoring this group.

And you are not done yet!

I will go on and on.

Happy new year.
 
J

James Kuyper

Paul said:
Ok, C99 has this. I don't know why, as this is *ALSO* a mechanism
mostly meant to make the OO system work (so constructors can be called
in a more controlled order.)

Delaying definition of a variable until the point where definition is
actually needed often allows you to declare it const (if it is indeed a
constant), which improves error detection and provides increased
opportunities for compiler optimization. This is more important for C++,
where the fact that it's const can determine which function override is
used, but it's not complete irrelevant in a C environment.
This has no place in C and, in fact, just leads to unreadable code.
It increases the time taken to search for a variable declaration by
about an order of magnitude.

I normally try to define each variable so that it has as small a scope
as possible (without gratuitous use of {} to create a smaller scope just
for the variable). I've personally found that this greatly reduces my
search times, because I don't have to search as far to find it. Mixing
declarations and statements allows me to shorten the scope even more,
which reduces it further.
 
R

Rico Secada

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.

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

Use C++.

You are trolling!
 
J

jacob navia

Masood said:
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

As you have seen, many people here were upset.

The compiler system lcc-win implements several of the improvements
of C++ within a purely C framework.
o operator overloading
o references
o default function arguments
o overloaded functions

It presents also other improvements like a garbage collector, 352
bits floats, 128 bits integers etc

You can download it at the URL below.
 
Y

ymuntyan

As you have seen, many people here were upset.

The compiler system lcc-win implements several of the improvements
of C++ within a purely C framework.
o operator overloading
o references
o default function arguments
o overloaded functions

It presents also other improvements like a garbage collector, 352
bits floats, 128 bits integers etc

You can download it at the URL below.

Could you stop it already?

Yevgen
 
C

CBFalconer

James said:
.... snip ...

I normally try to define each variable so that it has as small a
scope as possible (without gratuitous use of {} to create a smaller
scope just for the variable). I've personally found that this
greatly reduces my search times, because I don't have to search as
far to find it. Mixing declarations and statements allows me to
shorten the scope even more, which reduces it further.

Er, reducing function size does the same thing, and provides side
benefits. Use of the 'inline' marker can eliminate the object code
difference. :)
 
C

CBFalconer

Rico said:
No, they will not.


Use C++.

You are trolling!

No, he is just offering sensible advice. If you want the
characteristics of a language, the usual suggestion is to use that
language. Not to diddle another, functional language, to have some
half cooked rotten adopted characteristics of the other language.
 
M

Mark McIntyre

Even if you repeat that lie a thousand times it doesn't make it true...

Bad quality means that I very often ANSWER the questions posed instead
of saying like many of the regulars

No, bad quality means
a) you post answers that are subtly wrong, and when the errors are
pointed out, you utterly refuse to accept that you may be wrong

b) you post answers to completely offtopic posts, which attract further
offtopic posts, and when asked not to do this, you rant that you're being
personally attacked via imaginary sock puppets and other such paranoid
bull.
You do not cite any examples, but it is obvious that I have a different
view point than many here. That makes it for "bad advice" in your
opinion.

What makes it bad advice is that its either wrong, or offtopic. Take your
pick.
IN YOUR OPINION!

No, based on fact. When you post correct, topical material you'll find
you attract less contumely.
 
M

Mark McIntyre

"Vote", huh? Now that was a vote.

Yup. People were invited to offer an opinion. Those who had an opinion
voted.
Democracy, huh? If you want to call it
a vote, then call it what it is: a made up vote.

False. Every reader of CLC had a chance to vote. Many did so. The votes
of those people were counted and assigned.
So, that "majority" needs to be a majority.

It was. An electoral majority is defined in terms of those who vote.
Those who remain silent disenfranchise themselves and are not counted. If
you find this peculiar, I suggest a dose of real-world election study.
A rhetoric question, by the way: what part of "vocal minority" is not
understood?

The part where its relevant. All societies are run by vocal minorities.
And they're all self-selecting. In most cases their views are
representative of the wider population.

I suppose this means I am talking to a wall. Probably it's good.

Luckily for you, I forgot to plonk you. Its a mistake I've now rectified.
Richard loves to remind how he started that thread,

So what? How does that equate to claiming they're cool or good? You're
fully of horseshit.
 
P

Paul Hsieh

Delaying definition of a variable until the point where definition
is actually needed often allows you to declare it const (if it is
indeed a constant), which improves error detection and provides
increased opportunities for compiler optimization.

A compiler can always determine if a variable has const semantics
without programmer assistance.

As for error detection, when these cases arise, you are just as likely
able to wrap the declaration into a scope.
[...] This is more
important for C++, where the fact that it's const can determine
which function override is used, but it's not complete irrelevant
in a C environment.
This has no place in C and, in fact, just leads to unreadable
code. It increases the time taken to search for a variable
declaration by about an order of magnitude.

I normally try to define each variable so that it has as small a
scope as possible (without gratuitous use of {} to create a smaller
scope just for the variable).

That's great for some minimalist sense while you are *writing* the
code, but it then becomes impossible to *read* the code afterwards.
If you know variable declarations are always at the top of a scope,
you can always find your local variables in a fast, deterministic
way. The "gratuitous" {} 's give you the required indication to find
these declaration points easily.
I've personally found that this greatly reduces my
search times, because I don't have to search as far to find it.

If you are using a tool, maybe. But if you are scanning by eye?
There's simply no comparison. You have to linearly search the entire
sequence of lines, unless you already know how and where the variable
is used. You are, in other words, giving up on the natural
expressiveness of the language, in favor of burning neurons on this
kind of information or just being slower in reading code.
Mixing declarations and statements allows me to shorten the scope
even more, which reduces it further.

This just seems like a drive to a purpose that is wrong headed to
begin with. With C you have the opportunity to be optimally clear
about every variable in your program. They went and just messed that
up in C99 for no good purpose.
 
I

Ian Collins

Paul said:
A compiler can always determine if a variable has const semantics
without programmer assistance.
Only a psychic compiler can determine the programmer's intent and they
are rare indeed.
 
K

Keith Thompson

jacob navia said:
As you have seen, many people here were upset.

I hope you're aware that most of us were upset by the "C language
Taleban" insult, and not by the content of his question.
The compiler system lcc-win implements several of the improvements
of C++ within a purely C framework.
o operator overloading
o references
o default function arguments
o overloaded functions

It presents also other improvements like a garbage collector, 352
bits floats, 128 bits integers etc

You can download it at the URL below.

In other words, if you want a C-like language that supports operator
overloading, references, et al, then you can use C++ or you can use
lcc-win. Neither of this is really C (C doesn't have operator
overloading, for example). The major differences seen to be that (a)
lcc-win provides a smaller superset of C than C++ does, (b) lcc-win
probably goes to a bit more effort to maintain compatibility with
standard C, and (c) lcc-win is available only from a single vendor for
a single platform.

Perhaps using lcc-win is a good solution for some people, particularly
the OP. I personally wouldn't have much problem with you mentioning
it *if* you'd do the following each time: (a) acknowledge that it's
your work (and thus that you have an entirely understandable bias in
its favor), (b) acknowledge the set of platforms to which it's limited
(currently just MS Windows unless I've missed something), and (c)
suggest that further discussion should be directed to
comp.compilers.lcc. Don't assume that everyone is already aware of
this; not all readers have been following the newsgroup long enough to
know the background.

To be clear, this is not a set of rules that you must follow. This is
simply my opinion regarding what I think you should do. Others'
opinions will inevitably differ.
 
B

Ben Bacarisse

The compiler system lcc-win implements several of the improvements
of C++ within a purely C framework.
<extension list snipped>

Do you have a plan to implement C99? A full C99 implementation would
be more useful to many than extensions that lock programmers in to
your compiler.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top