comp.lang.c - 12 new messages in 7 topics - digest
comp.lang.c
http://groups.google.com/group/comp.lang.c?hl=en
Today's topics:
* Has thought been given given to a cleaned up C? Possibly called C+. - 3
messages, 3 authors
http://groups.google.com/group/comp.lang.c/t/5954dc70a43f9f8e?hl=en
* ANNOUNCE: WinGDB - debugging with GDB under Visual Studio - 1 messages, 1
author
http://groups.google.com/group/comp.lang.c/t/caa9b97bbee41cd4?hl=en
* How can I Compile this program using the alias Cgfx? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/7566e25a5d01da7b?hl=en
* question about macro? - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.c/t/78ed6f536b032cfc?hl=en
* Best way/library to draw individual pixels on screen? (for fractals) - 2
messages, 1 author
http://groups.google.com/group/comp.lang.c/t/bf4e0288d8537985?hl=en
* Efficency and the standard library - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/ad9fea19f2f7dd61?hl=en
* parsing practice - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/69eefd7d02a113a3?hl=en
==============================================================================
TOPIC: Has thought been given given to a cleaned up C? Possibly called C+.
http://groups.google.com/group/comp.lang.c/t/5954dc70a43f9f8e?hl=en
==============================================================================
== 1 of 3 ==
Date: Wed, Mar 10 2010 4:28 pm
From: Ben Bacarisse
Andrew Poelstra <apoelstra@localhost.localdomain> writes:
<snip>
> If there was an operator keyword (or something) that would declare
> a one-or-two parameter function to take its arguments in that style,
> there would be no need for extra keywords.
>
> Then you could have
>
> a = b pow c;
<OT>
Haskell does this with ``. Given a function f (of the right type) you
can write x `f` y. mod and div are done this way.
<even more OT>
Haskell also has the reverse. Given an operator like +, (+) is a
function that behaves like +. (+x) and (x+) are also functions, but
they are now the function that adds x to something.
</even more OT></OT>
<snip>
--
Ben.
== 2 of 3 ==
Date: Wed, Mar 10 2010 8:37 pm
From: Flash Gordon
Ian Collins wrote:
> On 03/11/10 08:14 AM, Andrew Poelstra wrote:
>> On 2010-03-10, Dag-Erling Smørgrav<des@des.no> wrote:
>>> Andrew Poelstra<apoelstra@localhost.localdomain> writes:
>>>> I think the biggest missing feature of C is namespaces.
>>>
>>> Agreed, but adding namespaces to the standard would be a lot of work,
>>> because there are a lot of corner cases to consider. There is also the
>>> issue of preprocessor macros, which can't be coerced into namespaces.
>>>
>>
>> Preprocessor macros would be an unfortunate edge case, but IMHO
>> not a fatal one. For function-like macros, you can use the inline
>> keyword on a function to get namespaces. For constants, you could
>> use an enum.
>>
>> What other corner cases can you think of?
>>
>> Feeling C++-ey would be simple enough without any standard library
>> changes:
>>
>> namespace std {
>> #include<stdio.h>
>> #include<stdlib.h>
>> }
>>
>> And boom, you've got std::malloc() and std::puts() and all that.
>>
>> Though now that I think about it, using that idea would probably
>> cause a fair bit of confusion for linkers.
>
> Unless there was a standard for mangled names in C. Namespaces require
> name mangling.
It doesn't need a standard for name mangling in the sense of something
added to the language standard. All it needs is for the implementation
(or OS) to decide on what method it will use (which can be considered a
standard for that particular implementation or OS), just as it has to
decide currently how simple names will be stored in the object file
(assuming there is such a thing).
A simple way of avoiding breaking anything existing is for the
implementation to decide that anything not in a namespace will be
unmangled, and anything defined as in a namespace will start with a
character which is not currently (for that implementation) a valid
character to start an identifier.
The confusion with the linker could be solved at the linker. If
currently the linker allows you to do "-lfoo" to link in foo, it could
allow "-lfoo:bar" to link in foo with a namespace of bar.
All these problems are solvable, and I agree it would be nice (from my
perspective) if they were solved. Whether it is worth the effort is
another matter, one which the standards bodies and compiler writers have
to decide on. Personally I suspect they will not implement namespaces in C.
--
Flash Gordon
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
== 3 of 3 ==
Date: Wed, Mar 10 2010 8:37 pm
From: Keith Thompson
jacob navia <jacob@jacob.remcomp.fr> writes:
[...]
> You have remained silent (as all other "regs") in the discussions
> about the library here.
>
> It is very easy. You limit yourself to piss at other people's proposals
> without ever proposing anything.
There you go again, jacob.
The "regs" have commented on your library. Please do not claim
otherwise.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
==============================================================================
TOPIC: ANNOUNCE: WinGDB - debugging with GDB under Visual Studio
http://groups.google.com/group/comp.lang.c/t/caa9b97bbee41cd4?hl=en
==============================================================================
== 1 of 1 ==
Date: Wed, Mar 10 2010 4:47 pm
From: Flash Gordon
Phred Phungus wrote:
> REH wrote:
>
>> There are a lot of GDB frontends Linux: Insight, KDBG, DDD, Eclipse. I
>> don't think any are as good as VS. My issue is I do a lot of GCC on
>> Windows, but GUIs for it are few an far between. And again, they are a
>> far cry from VS.
>>
>> REH
>
> Thx, that's good to know. My debuggers have been print statements since
> I went gnu.
>
> Question for you: if you had to coach a person with abilities and means
> like your own through a useful mingw install, how long would that take?
As long as it takes to say, "find MinGW and install it". It took me
twice as long to tell someone with less abilities than me to do a useful
(for his purposes) install of Cygwin, because I had to specify a few
packages to be selected.
Personally I like MSVC, but most of my development currently is for Linux.
--
Flash Gordon
==============================================================================
TOPIC: How can I Compile this program using the alias Cgfx?
http://groups.google.com/group/comp.lang.c/t/7566e25a5d01da7b?hl=en
==============================================================================
== 1 of 1 ==
Date: Wed, Mar 10 2010 4:58 pm
From: Flash Gordon
happytoday wrote:
> On Mar 8, 10:54 am, Ian Collins <ian-n...@hotmail.com> wrote:
>> happytoday wrote:
>>
>> [same old same old]
>>
>> What about the answers you received last year and in 2006?
>>
>> --
>> Ian Collins
>
> What about the non-complete answers I have been received last year and
> in 2006?
If the answers you received are not useful then you are unlikely to read
useful answers by asking in the same place again. So try asking people
who know about Cgfx instead.
--
Flash Gordon
==============================================================================
TOPIC: question about macro?
http://groups.google.com/group/comp.lang.c/t/78ed6f536b032cfc?hl=en
==============================================================================
== 1 of 3 ==
Date: Wed, Mar 10 2010 5:11 pm
From: Flash Gordon
Eric Sosman wrote:
> On 3/9/2010 4:09 PM, MBALOVER wrote:
>> Thanks a lot for responses.
>>
>> Let me explain why I do not want to use a inner loop.
>>
>> for (i=0;i<N;i++)
>> for (j=0;j<M;j++)
>> array2[i*M+j]=array1[i];
>>
>> for each for iteration of a for loop, we need a comparison and one
>> addition.
>
> Maybe, but optimizing compilers are already pretty good
> at unrolling loops -- especially loops whose iteration count
> are compile-time constants.
Yes, but possibly not enough. The OP needs to check this.
Personally, if the OP needs to do the full unroll, I would be inclined
to write a small C program to run on the ost system to generate the code
to be compiled for the target.
>> addition. In my system, each comparison takes 3 cycles and one
>> addition takes 1 cycle.
>> So each iteration takes 4 cycles.
>
> It was reasonable to count cycles as recently as, oh, twenty
> years ago. Since then, CPU's have become far more intricate and
> cycle counts have become extremely difficult to compute. Unless
> you're using an unusually simple processor (single-issue, little
> or no pipelining, at most one level of memory cache, maybe only
> a one- or two-slot store buffer, ...), these cycle counts are
> only loosely related to elapsed time.
It's not *that* long ago that I was programming an embedded processor
that had a trick three stage pipeline (all instructions when through all
three stages even if they only did something in one of them), no
out-of-order execution and no cache. So excluding wait states for memory
all instructions took in three cycles. However, in practice, due to the
pipelining, all instructions effectively took one cycle except in the
presence of a branch. The processor, and it's derivatives, are still
available today.
> Your example showed thirty assignments, and you indicated you
> might need as many as a thousand. How many cycles will you spend
> in wait states with the CPU twiddling its thumbs while RAM ever so
> slowly retrieves a fresh batch of instructions?
On the embedded system I was processing the memory and clock speeds
where carefully selected so there were no wait states.
>> If I use a inner loop, for each i, I need 4*M additional cycles. In
>> my case M , N both are large numbers and the system's time budget is
>> limited.
>>
>> That is why I do not want to use this way.
>
> Write it both ways (John Bode's suggestion of a "helper"
> program will save some time), and MEASURE the difference. Cycle
> counting is nearly impossible unless you happen to know that most
> of the data is already in CPU registers; a couple of cache misses
> (even just in L1) can disrupt the whole calculation. Measure!
I agree with measure, although *if* it is a simple enough processor (and
they are still out there) you *can* count.
--
Flash Gordon
== 2 of 3 ==
Date: Wed, Mar 10 2010 9:03 pm
From: Squeamizh
On Mar 10, 5:11 pm, Flash Gordon <s...@spam.causeway.com> wrote:
> Eric Sosman wrote:
> > On 3/9/2010 4:09 PM, MBALOVER wrote:
> >> Thanks a lot for responses.
>
> >> Let me explain why I do not want to use a inner loop.
>
> >> for (i=0;i<N;i++)
> >> for (j=0;j<M;j++)
> >> array2[i*M+j]=array1[i];
>
> >> for each for iteration of a for loop, we need a comparison and one
> >> addition.
>
> > Maybe, but optimizing compilers are already pretty good
> > at unrolling loops -- especially loops whose iteration count
> > are compile-time constants.
>
> Yes, but possibly not enough. The OP needs to check this.
>
> Personally, if the OP needs to do the full unroll, I would be inclined
> to write a small C program to run on the ost system to generate the code
> to be compiled for the target.
>
> >> addition. In my system, each comparison takes 3 cycles and one
> >> addition takes 1 cycle.
> >> So each iteration takes 4 cycles.
>
> > It was reasonable to count cycles as recently as, oh, twenty
> > years ago. Since then, CPU's have become far more intricate and
> > cycle counts have become extremely difficult to compute. Unless
> > you're using an unusually simple processor (single-issue, little
> > or no pipelining, at most one level of memory cache, maybe only
> > a one- or two-slot store buffer, ...), these cycle counts are
> > only loosely related to elapsed time.
>
> It's not *that* long ago that I was programming an embedded processor
> that had a trick three stage pipeline (all instructions when through all
> three stages even if they only did something in one of them), no
> out-of-order execution and no cache. So excluding wait states for memory
> all instructions took in three cycles. However, in practice, due to the
> pipelining, all instructions effectively took one cycle except in the
> presence of a branch. The processor, and it's derivatives, are still
> available today.
What processor? Just curious...
== 3 of 3 ==
Date: Thurs, Mar 11 2010 12:15 am
From: Phil Carmody
Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
> Ian Collins <ian-news@hotmail.com> writes:
>> MBALOVER wrote:
>>> Hi all,
>>>
>>> Actually I want my code to be
>>>
>>> for (i=0;i<N;i++)
>>> {
>>> array2[i*30]=array1[i];
>>> ..................
>>> array2[i*30+29]=array1[i];
>>> }
>>>
>>> If there anyway to use macros to do it instead for listing out
>>> manually in the code like above?
>>
>> Forget macros, they won't help here.
>>
>> How about memset?
On many installations, you'll find that's a macro! ;-)
>> (untested)
>>
>> memset( array2+i*30, array1[i], 30*sizeof(array2[0]) );
>
> As Keith has pointed out memset won't do. memcpy, on the other hand,
> can do it in 5 calls:
>
> array2[i+30] = array1[i];
> memcpy(array2+i*30 + 1, array2[i+30], sizeof array2[i]);
> memcpy(array2+i*30 + 2, array2[i+30], 2 * sizeof array2[i]);
> memcpy(array2+i*30 + 4, array2[i+30], 4 * sizeof array2[i]);
> memcpy(array2+i*30 + 8, array2[i+30], 8 * sizeof array2[i]);
> memcpy(array2+i*30 + 16, array2[i+30], 14 * sizeof array2[i]);
>
> Note the final multiplier (if I've go it right).
14's right. The +30's should be *30's.
I timed this against a naive loop for int, long long, and
double types. Conclusions were inconclusive. For double,
the naive loop was faster when compiled for plain i386, but
slower when 'optimised' for the actual athlon-xp architecture.
For int and long long, the memcpys were faster than the loop.
The memcpys were in fact simply unrolled completely.
Given that there was a case where the memcpys were measurably
slower, it's not worth blindly going for the clever technique
until you've both found that the naive loop is slowing you down
and measured the two to make sure that the optimisation is in
fact an improvement. Writing a clever version for speed without
measuring whether it's faster or not is dumb. And frequently
done, alas.
Phil
--
I find the easiest thing to do is to k/f myself and just troll away
-- David Melville on r.a.s.f1
==============================================================================
TOPIC: Best way/library to draw individual pixels on screen? (for fractals)
http://groups.google.com/group/comp.lang.c/t/bf4e0288d8537985?hl=en
==============================================================================
== 1 of 2 ==
Date: Wed, Mar 10 2010 11:08 pm
From: "Robbie Hatley"
"Wolfnoliir" asked:
> I would like to know what library and method you would recommend for
> displaying individual pixels on the screen in the scope of producing
> representations of fractals based on complex iteration (e.g. Mandelbrot
> or Julia). So it is important that the method be speed efficient.
> I would also be interested in knowing (very briefly) how one would go
> about making a video player inside a GTK application.
>
> I have some knowledge of SDL and OpenGL already.
I chose not to do it that way in my fractal graphing programs.
Instead, I researched the "*.bmp" file format, and write images
to "*.bmp" files.
Why do it that way? Several reasons:
1. You don't need any libraries.
2. You don't need any high-level languages.
(The whole thing can be done in C, or even in assembly.)
3. You don't need any GUIs.
(A simple CLI program can graph fractals this way.)
4. Why "*.bmp" format? Because it's the simplest and most
widely used of the "lossless" picture file formats.
5. If you later decide to go from a CLI to a GUI program
for Microsoft Windows, the Win32 API already includes
ability to draw "*.bmp" type bitmaps directly to the screen.
The hard part is figuring out the bmp headers, and creating
appropriate structs. Once you get over that hurdle, the rest
is just writing numbers to a 2d array, which is trivial.
http://picasaweb.google.com/LagrangeL2/Mandelbrot#5417146700980354674
http://picasaweb.google.com/LagrangeL2/Mandelbrot#5417146213849908562
--
Cheers,
Robbie Hatley
lonewolf at well dot com
www dot well dot com slant tilde lonewolf slant
== 2 of 2 ==
Date: Wed, Mar 10 2010 11:29 pm
From: "Robbie Hatley"
"Andrew Poelstra" wrote:
> "Squeamizh" wrote:
>
> > "Andrew Poelstra" wrote:
> >
> > > Qt is a quagmire of inconsistencies, undocumented bugs and missing
> > > functionality. And it forces you to use C++, which has all those
> > > problems on its own.
> >
> > C++ does not have all those problems on its own. I'm not sure why you
> > would say that.
>
> It does, though. Perhaps I worded that too strongly (it does
> look like a flame bait, even to me, though I assure you this
> was not my intent.)
>
> See http://www.yosefk.com/c++fqa
>
> for a critique from somebody quite passionate about this issue.
Yossi Kreinin is "passionate", all right, but if you read in depth,
You'll see that he doesn't just criticize C++, but says it's
good for nothing, and the wrong choice for EVERY use. He uses
the words "shitty" and "crappy" a lot on his web site in
reference to C++. I get the impression that C++ is just too much
language for him to handle.
This is especially evidenced by the fact that he slams C++ for
presenting so many alternate ways of doing things, especially
for having both C features (such as arrays) and C++ features
(such as std::vector). But I think that's one of the BEST points
of C++, not the worst; it gives the programmer the option of
either doing things "close to the machine" (such as by using
arrays, or malloc/free), or doing things at a higher level of
abstraction (such as with std::vector, or new/delete). For
a programmer who lacks conciousness of abstraction, this
plethora of choices would seem daunting. As it apparently does
to Yossi Kreinin.
--
Cheers,
Robbie Hatley
lonewolf at well dot com
www dot well dot com slant tilde lonewolf slant
==============================================================================
TOPIC: Efficency and the standard library
http://groups.google.com/group/comp.lang.c/t/ad9fea19f2f7dd61?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Mar 11 2010 12:15 am
From: "io_x"
"spinoza1111" <spinoza1111@yahoo.com> ha scritto nel messaggio
news:25c6d801-b2f9-4c79-8227-f5df27a69876@s25g2000prd.googlegroups.com...
On Feb 13, 5:25 pm, spinoza1111 <spinoza1...@yahoo.com> wrote:
#io_x
...latest code...
<snip>
In view of the face that NO OTHER POSTER (to my knowledge) has met the
requirements (code a string replace function without string.h usage) I
hereby declare victory, and award myself the Golden Spinoza Order of
Purity and Truth har har.
Seriously, I have demonstrated, I believe, that Republicans can't code
worth dick, but they can (if Peter Seebach is still a Republican) say
"there is a bug in my code but I'm fucked if I'll fix it", and they
sure can backstab and lie. That is: there is an entire programming
world-view, a Gestalt, that is complete malarkey and normalized
deviance. It consists of the inchoate saws and maxims that have
accumulated over time, that have sifted down from on-high from capable
early developers, but which have become little more than a cargo
cult.
My code is hard to read, it is said (on dit). In a sense, it is. I
find it hard to read at times myself.
#i find hard my code only at first see
#but if i think about it, i find it readable and easy
#
#if my code is hard it is because do complex things.
#if i have one problem is how to traslate one complex problem
#to his little one problems, but now i think not have it too
An entire story exists in the cargo cult of the programmer who is in
some versions of the story "too clever by half" and in others only
thinks he is, and who writes an enormous program that nobody can
figure out.
#people not understand because someone has experience of some language
#some routines, that other people not have
The social function of the story is to normalize
differences in ability, and to cover up the fact that many companies
try to solve ill-defined and very hard problems with computers, often
in order to exploit their workers or cheat customers. It omits the
existence of real code written by ordinary members of the white collar
proletariat which solved in an unsung fashion a hard problem...such as
the assembler for the 8K IBM 1401 that was written by a Univ of Chi
graduate student that put the IBM assembler to shame.
When looking for work in the 1990s, I answered an ad from Rockwell-
Wescom, a telecom manufacturer in Chicago. During my interview, the
manager said "some guy many years ago figured out how to use our call
data to reconstruct calls by simulating the PBX: he was pretty
strange." I said, "that was me". I'd become a legend of the dreamtime.
I didn't get a job because, the manager said, I was "too good to be
true". There had to be something wrong with a guy who'd solved a
problem nobody else could solve but was looking for work in his
forties.
Whereas at a shipping conference in 2003 I was greeted with
recognition by the staff of a shipbuilding firm for whom I'd created a
key program in the 1980s. This was because their culture was one of
openness and trust, not myth, and it's important that at the
conference, they said that they weren't bothering to bid for work in
Iraq. It was an ethical firm, of the sort that is in my experience
rare.
Code in some instance might look challenging because the problem is
actually a bit hard.
#and so the code for that problem could be hard
Likewise it was hard for NASA engineers to solve
the problem of O-ring temperatures in cold temperatures in the
Challenger space shuttle, and later for them to solve the problem of
foam insulation dropping off Columbia at launch.
"They say it couldn't be done. So, I didn't do it."
In a post-Enlightenment culture of real science that has sifted down
to low-level technicians distinguished only by their conformity,
passive-aggression, frightened political conservatism (or passive-
aggressive "libertarianism") and/or religious Fundamentalism, the
#yes possible i'm fundamentalist, when i convince myself of something
#it is not easy change idea for what say other when no code is show
former science (including Dijkstra's misinterpreted admonitions
concerning simplicity and "the humble programmer") become a cargo cult
of excuses for normalized deviance.
#to program, some time, is not easy and one has to be humble always
#because exist always that 90% that is better of me
#and each one has his/her way for write and for resolve problems
#and that way of resolve can not be simulated in another one people
In a recent collection of writings on popular music by my fat pal
Theodore Adorno, he sets out the contrast starkly between classical
and popular music, and this is applicable to programming.
Popular music, he wrote, seems free and liberating, but in actuality
is almost always oversimplified in structure (and this is still true
of pop music years after he wrote it). The dissonances and syncopation
rely for their effect, he wrote, on the fact that for the listener
they are not actual artistic and standalone statements, but instead
sardonic POINTERS (references) back to classical music, light
classical music, and more traditional pop music.
The pop composer, even Irving Berlin or Copland, relies for his effect
on a backreference which says inside the music "listen, I flatted that
note, but you can if you like normalize my deviance by treating what I
said as unserious".
Consider the difference between Phillip Glass or Ygor Stravinsky on
the one hand, and Alban Berg on the other. The audience, according to
a 1980s Time magazine article about Glass, happily "sighed" when
Glass's cheap backreferences to the most innocuous classical music
with an easy-listening rock beat started to drone. Likewise, the
anxious bourgeois applauded Stravinsky (and Picasso) in the 1920s when
they reverted to classical models by means of snarky backreferences
with just enough dissonance to make the audience feel hip.
Whereas Beethoven meant to write the entire symphony in such a way
that ANY change would damage the whole (whereas my formatting and
naming conventions are not something I can willingly discard). (I
really felt for Tom Hulce's Amadeus in the eponymous movie when he was
told to discard notes by the Emperor).
<snip>
==============================================================================
TOPIC: parsing practice
http://groups.google.com/group/comp.lang.c/t/69eefd7d02a113a3?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Mar 11 2010 12:15 am
From: Nick <3-nospam@temporary-address.org.uk>
"Bill Cunningham" <nospam@nspam.invalid> writes:
> This simple little program takes from stdin and writes to stdout.
No it doesn't. It never touches stdin.
It uses the parameters passed in argv, but that's nothing at all to do
with "taking from stdin".
--
Online waterways route planner | http://canalplan.eu
Plan trips, see photos, check facilities | http://canalplan.org.uk
==============================================================================
You received this message because you are subscribed to the Google Groups "comp.lang.c"
group.
To post to this group, visit http://groups.google.com/group/comp.lang.c?hl=en
To unsubscribe from this group, send email to comp.lang.c+unsubscribe@googlegroups.com
To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c/subscribe?hl=en
To report abuse, send email explaining the problem to abuse@googlegroups.com
==============================================================================
Google Groups: http://groups.google.com/?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home