Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44381
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <davea@davea.name> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.096 |
| X-Spam-Evidence | '*H*': 0.81; '*S*': 0.00; 'compiler': 0.07; 'function,': 0.09; 'string;': 0.09; 'sure,': 0.09; 'instance:': 0.16; 'operands': 0.16; 'questioned': 0.16; 'wrote:': 0.18; 'coding': 0.22; 'header:User-Agent:1': 0.23; 'char': 0.24; 'first,': 0.26; 'switch': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; "doesn't": 0.30; 'constant': 0.31; 'maybe': 0.34; "i'd": 0.34; 'problem': 0.35; 'knows': 0.35; 'something': 0.35; 'case,': 0.35; 'but': 0.35; 'there': 0.35; 'convention': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'helps': 0.61; 'skip:* 10': 0.61; "you're": 0.61; 'you.': 0.62; 'making': 0.63; 'protection': 0.63; 'soon': 0.63; 'benefit': 0.68; 'realized': 0.68; 'received:74.208': 0.68; 'const': 0.84; 'received:74.208.4.194': 0.84 |
| Date | Thu, 25 Apr 2013 23:43:08 -0400 |
| From | Dave Angel <davea@davea.name> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Comparison Style |
| References | <125c8f33-1a62-4dc0-9341-a2d8f7b58058@googlegroups.com> <CAPTjJmq6afVuQnXCyXNFV1QvYi_Pt2qT9tCmjBVUSvqOLunEhA@mail.gmail.com> <nqpjn81vrbluuegvj1ggvuhegdcvki6743@invalid.netcom.com> <CAPTjJmrwsC1NFB0Vk4H2_fy1+mS+ec41r-9OoFpkX5i5ZcJsXw@mail.gmail.com> |
| In-Reply-To | <CAPTjJmrwsC1NFB0Vk4H2_fy1+mS+ec41r-9OoFpkX5i5ZcJsXw@mail.gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Provags-ID | V02:K0:ERX4wQOckYYOPHnE+W7IfEB9UhWzKyFt5wGipKGyDWr RcaJ8v2Zejmtbm3ma6o3qKPBQ8T5T0rk2PuE+9OrCDmCB6G8wV gN53Exx6wQdgq1lEzWj7pH6AaLLNA9a7s/Rl7GYnSja/O4j8HH RJNFmJ+EK38ueDLFvVj3x0L/A4tN+pI4oKh566x9JZPv1s2c6+ wJNQpHYJ0wSikXptxGEqa+6zOxPVRSQ9a9ArxjcGbeLw1bc/l5 mEZk9k1YLwNWbg4kOw8PS3Gv5NASo4vgF4nG3rQRA8IiP4Jyfw gQia5k2fOaHaJFngIu1GoORMqdKVFYEPMbaueuxUP+uu4C/Sw= = |
| 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 | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1079.1366947835.3114.python-list@python.org> (permalink) |
| Lines | 40 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1366947835 news.xs4all.nl 15877 [2001:888:2000:d::a6]:56050 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:44381 |
Show key headers only | View raw
On 04/25/2013 10:48 PM, Chris Angelico wrote:
<SNIP>
> Also, this protection helps only when the "constant"
> is actually something the compiler knows is a constant - it doesn't
> work in a search function, for instance:
>
> char *strchr(char *string, char findme) {
> while (*string) {
> if (*string==findme) return string;
> ++string;
> }
> return 0;
> }
Sure, but if I were coding in C again, I'd have made that function signature
char *strchr(char *string, const char findme) {
or maybe
char *strchr(const char *string, const char findme) {
>
> If you switch the order of operands in that, the compiler won't help
> you.
Yes, it would.
> Plus it "reads" wrong. So the convention is still
> variable==constant.
In my case, after having it drilled in that you're "supposed" to put the
constant first, I realized that I never had any problem with using =,
because as soon as I questioned the order, I just double-checked that I
was using ==. At that point, there was no longer any benefit to making
the order backwards.
--
DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Comparison Style llanitedave <llanitedave@veawb.coop> - 2013-04-24 22:49 -0700
Re: Comparison Style Chris Angelico <rosuav@gmail.com> - 2013-04-25 15:57 +1000
Re: Comparison Style llanitedave <llanitedave@veawb.coop> - 2013-04-25 07:19 -0700
Re: Comparison Style Chris Angelico <rosuav@gmail.com> - 2013-04-26 02:25 +1000
Re: Comparison Style Steve Simmons <square.steve@gmail.com> - 2013-04-25 19:31 +0100
Re: Comparison Style llanitedave <llanitedave@veawb.coop> - 2013-04-25 13:13 -0700
Re: Comparison Style Neil Cerutti <neilc@norwich.edu> - 2013-04-25 20:15 +0000
Re: Comparison Style Steve Simmons <square.steve@gmail.com> - 2013-04-25 21:35 +0100
Re: Comparison Style Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-04-26 10:02 +0100
Re: Comparison Style Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-04-25 22:37 -0400
Re: Comparison Style Chris Angelico <rosuav@gmail.com> - 2013-04-26 12:48 +1000
Re: Comparison Style Roy Smith <roy@panix.com> - 2013-04-27 17:03 -0400
Re: Comparison Style Terry Jan Reedy <tjreedy@udel.edu> - 2013-04-27 17:40 -0400
Re: Comparison Style Dave Angel <davea@davea.name> - 2013-04-25 23:43 -0400
csiph-web