Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #59500
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.017 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'operator': 0.03; 'float': 0.07; '#define': 0.09; '#include': 0.09; 'main()': 0.09; 'c/c++': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'inaccurate': 0.16; 'other)': 0.16; 'roy': 0.16; 'value;': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'header': 0.24; '15,': 0.26; '2.0': 0.26; 'this:': 0.26; 'somewhere': 0.26; 'header:In- Reply-To:1': 0.27; 'to?': 0.30; 'message-id:@mail.gmail.com': 0.30; 'struct': 0.31; 'file': 0.32; 'fri,': 0.33; 'totally': 0.33; 'received:google.com': 0.35; 'should': 0.36; 'application': 0.37; 'nov': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'most': 0.60; 'smith': 0.68; 'hey,': 0.75; 'power': 0.76; '"look': 0.84; 'horrible': 0.84; 'subject: #': 0.96; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=jTXhFAZ5RgvOauMAa8vt7jY6UhULGWxYrlQrbtFuZgM=; b=xIObJr912WJ2XWPAerhPPAQBIrM7sTvlWSBYWe4i1f2z1OibRVp7AWTgg/74zf4FJu weZXwzki6DDCPlQMbKSzFlIgFZjMmYFkbSso2D+A40+jfyNY9ryUeb25VPXdYHuhvueM Y55tUDYESdN0HfdljUKU0Apg2LSjJc1OQCc/IT9pjJaKUN2eGwk6ZPdKaChRsr9K1r5g tXnBp5G7X/NZwnjdny7sZKoopDGVe9yEd3qfNl2LWpSKdoRe322sq9jFIQNCDyXPh/X9 XVHqfLNQj113ZCsCuBj76R+wUTuYmS1Ipq6Knl5/F0xU538VLvhs19bBZ7WoB0z8oXLb GFXQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.66.155.102 with SMTP id vv6mr4987544pab.89.1384491426081; Thu, 14 Nov 2013 20:57:06 -0800 (PST) |
| In-Reply-To | <roy-2E4CE0.23100314112013@news.panix.com> |
| References | <fae7479b-ecec-4114-9750-6595fa8c78fa@googlegroups.com> <roy-2E4CE0.23100314112013@news.panix.com> |
| Date | Fri, 15 Nov 2013 15:57:05 +1100 |
| Subject | Re: Implementing #define macros similar to C on python |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2638.1384491435.18130.python-list@python.org> (permalink) |
| Lines | 32 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1384491435 news.xs4all.nl 15887 [2001:888:2000:d::a6]:54560 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:59500 |
Show key headers only | View raw
On Fri, Nov 15, 2013 at 3:10 PM, Roy Smith <roy@panix.com> wrote:
> Why would you want to? One of the most horrible things about C/C++ is
> the preprocessor.
Hey, that's not fair! Without the preprocessor, how would you be able
to do this:
//Hide this part away in a header file somewhere
struct b0rkb0rk
{
float value;
b0rkb0rk(float v):value(v) {}
operator float() {return value;}
float operator +(float other) {return value+other-0.1;}
};
//Behold the power of the preprocessor!
#define float b0rkb0rk
//Okay, now here's your application
#include <iostream>
int main()
{
std::cout << "Look how stupidly inaccurate float is!\n";
float x = 123.0f;
std::cout << "123.0 + 2.0 = " << x + 2.0f << "\n";
std::cout << "See? You should totally use double instead.\n";
}
(Anybody got a cheek de-tonguer handy? I think it's stuck.)
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Implementing #define macros similar to C on python JL <lightaiyee@gmail.com> - 2013-11-14 18:29 -0800
Re: Implementing #define macros similar to C on python Dave Angel <davea@davea.name> - 2013-11-14 21:30 -0600
Re: Implementing #define macros similar to C on python Chris Angelico <rosuav@gmail.com> - 2013-11-15 14:49 +1100
Re: Implementing #define macros similar to C on python JL <lightaiyee@gmail.com> - 2013-11-15 15:36 -0800
Re: Implementing #define macros similar to C on python Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2013-11-16 01:20 +0100
Re: Implementing #define macros similar to C on python Terry Reedy <tjreedy@udel.edu> - 2013-11-15 19:22 -0500
Re: Implementing #define macros similar to C on python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-16 00:22 +0000
Re: Implementing #define macros similar to C on python JL <lightaiyee@gmail.com> - 2013-11-15 21:38 -0800
Re: Implementing #define macros similar to C on python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-16 11:48 +0000
Re: Implementing #define macros similar to C on python Roy Smith <roy@panix.com> - 2013-11-14 23:10 -0500
Re: Implementing #define macros similar to C on python Chris Angelico <rosuav@gmail.com> - 2013-11-15 15:57 +1100
Re: Implementing #define macros similar to C on python Serhiy Storchaka <storchaka@gmail.com> - 2013-11-16 12:02 +0200
Re: Implementing #define macros similar to C on python Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2013-11-16 00:20 +0100
csiph-web