[Cfp-interest] type-generic cbrt for decimal

Jim Thomas jaswthomas at sbcglobal.net
Thu Dec 13 21:14:19 PST 2012


I put the example in. Let's review it (when posted) and decide in January whether to keep it.

-Jim

On Dec 11, 2012, at 12:50 PM, Rajan Bhakta wrote:

> I know you said that this one argument example is not needed, however I think examples are usually very useful when reading any spec, and having even this simple case in the message below would be useful. I agree we shouldn't go further than the one argument example though. 
> 
> Regards,
> 
> Rajan Bhakta
> z/OS XL C/C++ Compiler Technical Architect
> ISO C Standards Representative for Canada
> C Compiler Development
> Contact: rbhakta at ca.ibm.com, Rajan Bhakta/Toronto/IBM
> Telephone: (905) 413-3995 
> 
> 
> From:	Jim Thomas <jaswthomas at sbcglobal.net>
> To:	CFP <cfp-interest at ucbtest.org>,
> Date:	12/11/2012 02:07 PM
> Subject:	[Cfp-interest] type-generic cbrt for decimal
> Sent by:	cfp-interest-bounces at oakapple.net
> 
> 
> 
> 
> Regarding 
> ISSUE 7: We intend to add an example showing how generic selection can be used to define cbrt for tgmath to handle decimal as well as generic FP types.
> 
> in Part 2, I'm wondering if providing the example is really desirable.
> 
> An implementation that supports Parts 1 and 2 might implement the cbrt type-generic macro as:
> 
> #ifdef __STDC_WANT_IEC_00000_EXT2
> 
> #define cbrt(X)  _Generic((X),                                               \
>                                         _Decimal128: cbrtd128(X),              \
>                                         _Decimal64: cbrtd64(X),              \
>                                         _Decimal32: cbrtd32(X),              \
>                                         long double: cbrtl(X),              \
>                                         default: _Roundwise_cbrt(X),  \
>                                         float: cbrtf(X)                           \
>                                         ) 
> #else 
> #define cbrt(X)  _Generic((X),                                               \
>                                         long double: cbrtl(X),              \
>                                         default: _Roundwise_cbrt(X),  \
>                                         float: cbrtf(X)                           \
>                                         ) 
> #endif
> 
> where _Roundwise_cbrt() is equivalent to cbrt() invoked without macro-replacement suppression. 
> 
> However, implementing a 2 or 3 argument function using _Generic, which is already prohibitively cumbersome with just C11, would become even worse with decimal types. It's difficult to imagine an implementation would do it, even without decimal types. 
> 
> If the example is just for programmers writing type-generic macros for their own 1-argument functions, then this straightforward example isn't really needed. 
> 
> Your thoughts? 
> 
> -Jim 
> 
> _______________________________________________
> Cfp-interest mailing list
> Cfp-interest at oakapple.net
> http://mailman.oakapple.net/mailman/listinfo/cfp-interest
> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20121213/ebf09f6b/attachment.html 


More information about the Cfp-interest mailing list