Re: a nifty feature for c preprocessor

2012-01-01 Thread Ruben Safir
On 01/01/2012 12:42 AM, Robert Dewar wrote: On 12/31/2011 4:44 AM, R A wrote: alright, here's another example why eval is a good idea: #define A 17 #define B 153 #define N1 ((A + B)/2) /* intended was (17 + 153)/2 */ #undef A #define A 230 #define N2

Re: a nifty feature for c preprocessor

2012-01-01 Thread David Brown
On 31/12/11 10:44, R A wrote: alright, here's another example why eval is a good idea: #define A 17 #define B 153 #define N1 ((A + B)/2) /* intended was (17 + 153)/2 */ #undef A #define A 230 #define N2 ((A + B)/2) /* intended was (230 + 153)/2 */ prin

RE: a nifty feature for c preprocessor

2012-01-01 Thread Richard Kenner
> i don't know if you're trying to be funny... > > but what's between the definition of N1 and the undef of A may be a very > complex. it's just simplified for demonstration. It's not good programming practice to have a macro (in this case A) have two different values, with an #undef between then

RE: a nifty feature for c preprocessor

2012-01-01 Thread R A
acore.com > To: ren_zokuke...@hotmail.com > CC: gcc@gcc.gnu.org > Subject: Re: a nifty feature for c preprocessor > > On 12/31/2011 4:44 AM, R A wrote: > > > > alright, here's another example why eval is a good idea: > > > > #define A 17 > > #define B 153

Re: a nifty feature for c preprocessor

2011-12-31 Thread Robert Dewar
On 12/31/2011 4:44 AM, R A wrote: alright, here's another example why eval is a good idea: #define A 17 #define B 153 #define N1 ((A + B)/2) /* intended was (17 + 153)/2 */ #undef A #define A 230 #define N2 ((A + B)/2) /* intended was (230 + 15

RE: a nifty feature for c preprocessor

2011-12-31 Thread R A
alright, here's another example why eval is a good idea: #define A 17 #define B 153 #define N1 ((A + B)/2) /* intended was (17 + 153)/2 */ #undef A #define A 230 #define N2 ((A + B)/2) /* intended was (230 + 153)/2 */ printf("%u %u", N1, N2);

Re: a nifty feature for c preprocessor

2011-12-30 Thread Basile Starynkevitch
On Thu, 29 Dec 2011 13:12:19 -0800 Ian Lance Taylor wrote: > Any gcc developer who feels that this proposal is a good idea, please > chime in here. > > I personally do not feel it is worth the effort. It's easy to use a > more powerful macro processor, such as m4, to generate your C code. I a

RE: a nifty feature for c preprocessor

2011-12-29 Thread R A
i meant "general purpose" macro processor. sorry.

RE: a nifty feature for c preprocessor

2011-12-29 Thread R A
--- > Date: Thu, 29 Dec 2011 16:30:04 -0800 > Subject: Re: a nifty feature for c preprocessor > From: james.denn...@gmail.com > To: david.br...@hesbynett.no > CC: ren_zokuke...@hotmail.com; gcc@gcc.gnu.org . > > I'd tend to agree; we o

Re: a nifty feature for c preprocessor

2011-12-29 Thread James Dennett
On Thu, Dec 29, 2011 at 1:50 PM, David Brown wrote: > On 29/12/11 22:05, R A wrote: >> >> >>> The gcc developers, and everyone else involved in the development >>> of C as a language, are perhaps not superhuman - but I suspect >>> their combined knowledge, experience and programming ability >>> ou

Re: a nifty feature for c preprocessor

2011-12-29 Thread Ian Lance Taylor
R A writes: >> This particular extension seems problematic when cross-compiling. In >> what environment should the expressions be evaluated? > > > why > are you asking for a specific environment? it's coding convenience and > elegance for coding in c itself. simplest case scenario is what i've

Re: a nifty feature for c preprocessor

2011-12-29 Thread David Brown
On 29/12/11 22:05, R A wrote: The gcc developers, and everyone else involved in the development of C as a language, are perhaps not superhuman - but I suspect their combined knowledge, experience and programming ability outweighs yours. given. but do you have a consensus of the community that

RE: a nifty feature for c preprocessor

2011-12-29 Thread R A
> I personally do not feel it is worth the effort. It's easy to use a > more powerful macro processor, such as m4, to generate your C code. The > benefit of building a more powerful macro processor into the language > proper seems minimal. > > This particular extension seems problematic when cross

RE: a nifty feature for c preprocessor

2011-12-29 Thread Richard Kenner
> given. but do you have a consensus of the community that this > feature is not worth including? i haven't even heard but from a few > people saying that "it's not worth it because if it was, 'we're the > ones to have thought about it'". No, that's not what people are saying. It's important to t

Re: a nifty feature for c preprocessor

2011-12-29 Thread Xinliang David Li
The idea sounds useful to me .. Or perhaps introduce template into C :) David On Thu, Dec 29, 2011 at 1:12 PM, Ian Lance Taylor wrote: > R A writes: > >>> The gcc developers, and everyone else involved in the development of C >>> as a language, are perhaps not superhuman - but I suspect their

Re: a nifty feature for c preprocessor

2011-12-29 Thread Ian Lance Taylor
R A writes: >> The gcc developers, and everyone else involved in the development of C >> as a language, are perhaps not superhuman - but I suspect their combined >> knowledge, experience and programming ability outweighs yours. > > given. but do you have a consensus of the community that this fea

RE: a nifty feature for c preprocessor

2011-12-29 Thread R A
> The gcc developers, and everyone else involved in the development of C > as a language, are perhaps not superhuman - but I suspect their combined > knowledge, experience and programming ability outweighs yours. given. but do you have a consensus of the community that this feature is not worth

Re: a nifty feature for c preprocessor

2011-12-29 Thread David Brown
On 29/12/2011 00:08, R A wrote: And if you want portable pre-processing or code generation, use something that generates the code rather than inventing tools and features that don't exist, nor will ever exist. It is also quite common to use scripts in languages like perl or python to generate t

FW: a nifty feature for c preprocessor

2011-12-28 Thread R A
sorry: 2) it takes very little penalty, otherwise.

RE: a nifty feature for c preprocessor

2011-12-28 Thread R A
> And if you want portable pre-processing or code generation, use > something that generates the code rather than inventing tools and > features that don't exist, nor will ever exist. It is also quite common > to use scripts in languages like perl or python to generate tables and > other pre-calcu

Re: a nifty feature for c preprocessor

2011-12-28 Thread David Brown
------- Date: Wed, 28 Dec 2011 10:57:28 +0100 From: da...@westcontrol.com To: ren_zokuke...@hotmail.com CC: gcc@gcc.gnu.org Subject: Re: FW: a nifty feature for c preprocessor On 28/12/2011 07:48, R A wrote: i'm an amateur programmer that just started learning C. i like most of t

Re: a nifty feature for c preprocessor

2011-12-28 Thread Jonathan Wakely
On 28 December 2011 21:06, Jonathan Wakely wrote: > On 28 December 2011 20:57, R A wrote: >> >> templates, i have no problem with, i wish there could be a C dialect that >> can integrate it, so i wouldn't have to be forced to use C++ and all the >> bloat that usually come from a lot of it's imple

Re: a nifty feature for c preprocessor

2011-12-28 Thread Jonathan Wakely
On 28 December 2011 20:57, R A wrote: > > templates, i have no problem with, i wish there could be a C dialect that can > integrate it, so i wouldn't have to be forced to use C++ and all the bloat > that usually come from a lot of it's implementation (by that i mean a > performance close to C i

RE: a nifty feature for c preprocessor

2011-12-28 Thread R A
Date: Wed, 28 Dec 2011 10:57:28 +0100 > From: da...@westcontrol.com > To: ren_zokuke...@hotmail.com > CC: gcc@gcc.gnu.org > Subject: Re: FW: a nifty feature for c preprocessor > > On 28/12/2011 07:48, R A wrote: > > > > i'm an amateur programmer that just started

Re: FW: a nifty feature for c preprocessor

2011-12-28 Thread David Brown
On 28/12/2011 07:48, R A wrote: i'm an amateur programmer that just started learning C. i like most of the features, specially the c preprocessor that it comes packed with. it's an extremely portable way of implementing metaprogramming in C. though i've always thought it lacked a single feature

FW: a nifty feature for c preprocessor

2011-12-27 Thread R A
i'm an amateur programmer that just started learning C. i like most of the features, specially the c preprocessor that it comes packed with. it's an extremely portable way of implementing metaprogramming in C. though i've always thought it lacked a single feature -- an "evaluation" feature. s