C needs a BOOST

¬

¬a\\/b

In data Sat, 06 Oct 2007 13:10:44 -0700, Keith Thompson scrisse:
If you're going to introduce an operator that does string
concatenation, you already have a requirement for some kind of
automatic storage management (either automatic garbage collection or
automatic destructors for the temporary string objects). And you
probably need an actual string type, something that C doesn't have.

sstring globalvalue;

so where is the problem if a+b return the partial (and at end the
total) result in "globalvalue"?

is the problem if "globalvalue" no resized to 0 memory very ofthen?

than there is the problem ("123"+"457") + ("123"+"456")
if the 2 () have the same precedence
 
M

Malcolm McLean

¬a\/b said:
than there is the problem ("123"+"457") + ("123"+"456")
if the 2 () have the same precedence
Can't see anything difficult about that. Parentheses however are superfluous
beacuse concatenation is inherently associative.

("Fred" + "is") + "dead" = "Fred" + ("is" + "dead")

for all values of Fred.
 
M

Malcolm McLean

Chris Thomasson said:
Chris Thomasson said:
[...]
Okay... We can have the 'clc_slist_push/init' functions return 'void*'
in order to do away with the casting; here is the "fresher/newer"
proposed API:
[...]

I think I will post the proposal/example code/api under the following
subject:


'The CLC Standard: LIFO Collection API Proposal'

Okay. Here is the initial code:


http://appcore.home.comcast.net/misc/clc_stack_c.html


I wanted to run this by all of you before I stick this thing in its own
thread...


Well, how crappy is it?

static clc_stack the_stack = CLC_STACK_STATIC_INIT();

read my 10 Rules of Programming before going any further.

This one breaks the rule of two. For something as fundamental as a stack,
the rule of two is very important.
 
S

Spiro Trikaliotis

Hello,

Stan said:
user923005 wrote: [...]
Opinions? Is keeping the language tiny worth the cost of C
programmers having to constantly reinvent the wheel?

This is what libraries are for. If you are like me you have built up a
"toolbox" of useful routines over the years.

But this might open a legal problem: If you have written some part of
the toolbox while working for one company, are you allowed to reuse this
for the next one? In many cases, this is not the case, thus, you have to
rewrite your toolbox once you change the company.

Not to take into account the problems that arise if you are working on
open-source and non-open-source projects...

Just my 2 cents worth.

Regards,
Spiro.
 
¬

¬a\\/b

In data Sun, 7 Oct 2007 09:15:04 +0100, Malcolm McLean scrisse:
Can't see anything difficult about that. Parentheses however are superfluous
beacuse concatenation is inherently associative.

("Fred" + "is") + "dead" = "Fred" + ("is" + "dead")

for all values of Fred.

in how i see the thing (don't know if compiler follow me)
in ("123"+"457") + ("123"+"456")

first there is
tm1=("123"+"457") , tm1=("123"+"456")
than
return tm1+tm1

so if there is only one golbal variable "tm1" for doing the sum
at the end there will be a wrong result

but with one only variable tm1 all is ok with
"123"+"457" + "123" + "456";
because it is ((("123"+"457") + "123") + "456");
tm1=("123"+"457");
tm1+="123";
tm1+="456";
return tm1;
 
C

Chris Thomasson

Malcolm McLean said:
Chris Thomasson said:
news:[email protected]... [...]>> Well, how crappy is it?

static clc_stack the_stack = CLC_STACK_STATIC_INIT();

read my 10 Rules of Programming before going any further.

I need to use CLC as a macro namespace... I need to use STACK as a micro
namespace... Anything else is a function of the micro... Therefore:
This one breaks the rule of two. For something as fundamental as a stack,
the rule of two is very important.
[...]

CLC_STACK_STATICINIT();

should satisfy you? BTW, thanks for taking a look!
 
C

Chris Thomasson

Malcolm McLean said:
Chris Thomasson said:
Chris Thomasson said:
[...]
Okay... We can have the 'clc_slist_push/init' functions return 'void*'
in order to do away with the casting; here is the "fresher/newer"
proposed API:
[...]

I think I will post the proposal/example code/api under the following
subject:


'The CLC Standard: LIFO Collection API Proposal'

Okay. Here is the initial code:


http://appcore.home.comcast.net/misc/clc_stack_c.html


I wanted to run this by all of you before I stick this thing in its own
thread...


Well, how crappy is it?

static clc_stack the_stack = CLC_STACK_STATIC_INIT();

read my 10 Rules of Programming before going any further.

BTW, do middle names confuse some people?

Chris Thomasson is my name:

Christopher Michael Thomasson is also my name...


So be it.
 
M

Malcolm McLean

Chris Thomasson said:
BTW, do middle names confuse some people?

Chris Thomasson is my name:

Christopher Michael Thomasson is also my name...
So be it.
They are not used. Your name is Christopher Michael Thomasson but you post
as Chris Thomasson. Instinctively people use a binomial system. That's the
rule of two.
 
F

Flash Gordon

Malcolm McLean wrote, On 07/10/07 15:49:
They are not used. Your name is Christopher Michael Thomasson but you
post as Chris Thomasson. Instinctively people use a binomial system.
That's the rule of two.

Some people *do* use there middle name. Also, as you should be well
aware, a number of people have double barrelled surnames, so even if
they do not use there middle name they are still using three names.

Personally, I have always used two names and my middle initial on
written stuff everywhere except on Usenet, and it has never confused people.

I think you vastly underestimate people with your "rule of two" and that
the name Christopher used was fine.
 
R

Richard Heathfield

Flash Gordon said:

I think you vastly underestimate people with your "rule of two" and that
the name Christopher used was fine.

Have you read the "rule of four" and the "rule of seven"?
 
F

Flash Gordon

Richard Heathfield wrote, On 07/10/07 19:39:
Flash Gordon said:



Have you read the "rule of four" and the "rule of seven"?

Well, I know a "rule of seven" and I suppose inflation could have hit
the "rule of three" that I know...
 
C

Chris Thomasson

Malcolm McLean said:
They are not used. Your name is Christopher Michael Thomasson but you post
as Chris Thomasson. Instinctively people use a binomial system.

I use my full name on most legal documents, reports, ect...


That's the rule of two.

I find that I need to break the rule of two from time to time, for practical
reasons...
 
R

Richard Heathfield

Chris Thomasson said:
I find that I need to break the rule of two from time to time, for
practical reasons...

Practically, there is no "rule of two" anyway. It's just something that
Malcolm has made up. A "rule of two" assumes that the number two not only
exists but is a significant and therefore reasonable number. But in fact
there are only four reasonable numbers. They are 0, 1, 4, and infinity (if
we can temporarily consider infinity to be a number).

0 is reasonable because it makes sense that you can't (or mustn't) do
something. (For example: how many leading underscores may you use in
external identifiers? Answer: None.)
1 is reasonable because it makes sense that you can do something only once.
(For example: how many definitions of main can your program have? Answer:
One.)
Infinity is reasonable because it makes sense that you can do something
lots of times. (For example: how many different unique external identifier
names are legal in C? Answer:
49684374567448041538025252381239447556479204485973162548 - which is
*effectively* infinite!)

And of course 4 is reasonable because it makes sense that the number of
reasonable numbers in existence should itself be reasonable. :)
 
C

Chris Thomasson

Richard Heathfield said:
Chris Thomasson said:


Practically, there is no "rule of two" anyway. It's just something that
Malcolm has made up. A "rule of two" assumes that the number two not only
exists but is a significant and therefore reasonable number. But in fact
there are only four reasonable numbers. They are 0, 1, 4, and infinity (if
we can temporarily consider infinity to be a number).

I like to think of an infinite number as a simple monotonic counter, that
never overflows...


0 is reasonable because it makes sense that you can't (or mustn't) do
something. (For example: how many leading underscores may you use in
external identifiers? Answer: None.)

1 is reasonable because it makes sense that you can do something only
once.
(For example: how many definitions of main can your program have? Answer:
One.)
Infinity is reasonable because it makes sense that you can do something
lots of times. (For example: how many different unique external identifier
names are legal in C? Answer:
49684374567448041538025252381239447556479204485973162548 - which is
*effectively* infinite!)

effectively infinite until one infinite counter syncs with another...


And of course 4 is reasonable because it makes sense that the number of
reasonable numbers in existence should itself be reasonable. :)

;)
 
C

Charlie Gordon

André Gillibert said:
Yes, you're most probably right for poems.

Actually, the French Surréalists invented a game of producing phrases by a
group of people: http://fr.wikipedia.org/wiki/Cadavre_exquis
http://en.wikipedia.org/wiki/Exquisite_corpse
The very name of the game is the first phrase they produced:
"Le cadavre - exquis - boira - le vin - nouveau"

It does not strictly qualify as a poem, but definety as poetry.

La révolution surréaliste - Cadavres exquis (1927) Extraits :
L'amour ornera le peuple.
Les femmes blessées faussent la guillotine aux cheveux blonds.
La colombe des branches contamine la pierre lamartinienne.
L'hippogriffe frisé poursuit la biche noire.
La grève des étoiles corrige la maison sans sucre.
Le mille-pattes amoureux et frêle rivalise de méchanceté avec le cortège
languissant.
La vapeur ailée séduit l'oiseau fermé à clé.
 
C

Charlie Gordon

jxh said:
Well, the obvious hyperbole aside, the following code:

template <typename T>
struct T_listnode {
T value;
struct T_listnode<T> *next;
};

would work both in C++ and in the hypothetical C template
implementation. So, in principle the C++ implementation could
just stand as is in the C implementation. Everything else you
mentioned is QOI.

Why use this horrible syntax ?
Here is an alternative:

struct T_listnode(typename T) {
T value;
struct T_listnode(T) *next;
};
 
H

Hartmut Brandt

On Sat, 6 Oct 2007, jacob navia wrote:

jn>Ian Collins wrote:
jn>> jacob navia wrote:
jn>> > Constructors and destructors look simple but are HELL to implement:
jn>> >
jn>> > int foo(int n)
jn>> > {
jn>> > int arg;
jn>> > // ...
jn>> > if (arg > 0)) {
jn>> > struct foo;
jn>> > // ... some code
jn>> > goto exit;
jn>> > // ... some code
jn>> > }
jn>> > exit:
jn>> > return 56;
jn>> > }
jn>> >
jn>> > The destructor of foo needs to be called before the goto gets
jn>> > executed... This was a bug still in MSVC some years ago.
jn>> >
jn>> The simple solution to that is to get rid of that decrepit relic from a
jn>> past age, goto!
jn>>
jn>> The only possible justification for using goto is cleanup code, which
jn>> can be cleanly handled with destructors.
jn>>
jn>
jn>How do you get rid of the goto?
jn>
jn>int Search_byName(char *name,int HowtoSearch)
jn>{
jn> switch(HowtoSearch) {
jn> // ...
jn> case 42:
jn> for (int i=0; i<Len; i++) {
jn> if (!strcmp(name,nameTab))
jn> goto found; // <<<<--
jn> }
jn> fprintf(stderr,
jn> "Not found\,%s is an illegal name);
jn> return 0;
jn> case 65:
jn> // ...
jn> }
jn> return -1;
jn>found:
jn> // Some code
jn> return 1;
jn>}
jn>
jn>The break statement has no arguments, and for breaking out
jn>of several nested scopes you *have* to use gotos.
jn>
jn>We have discussed this in comp.std.c several times. There were proposals
jn>to give an argument to break, like in this case
jn> break found;
jn>
jn>but it was argued that this would be identical to goto...

break, continue and return are all forms of hidden gotos (and very useful
as is goto). Go and write the above in Pascal. I mean the original Pascal,
not Turbo Pascal.

I think bashing goto nowadays is just silly...

harti
 
S

santosh

Hartmut said:
break, continue and return are all forms of hidden gotos (and very
useful as is goto). Go and write the above in Pascal. I mean the
original Pascal, not Turbo Pascal.

I think bashing goto nowadays is just silly...

goto isn't inherently bad, but it is very easy for someone to abuse it
when better control flow methods are available.

Bashing goto is silly, as is singing it's praises.
 

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,774
Messages
2,569,596
Members
45,144
Latest member
KetoBaseReviews
Top