This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author loewis
Recipients loewis, pitrou, vstinner
Date 2012-08-03.12:15:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1343996120.86.0.149995813205.issue15530@psf.upfronthosting.co.za>
In-reply-to
Content
Victor hinted that it would detect errors when combining int and unsigned int. To elaborate, see the attached min.c. It gives

[traditional MIN definition]
  [int, pointer]
min.c:18: warning: comparison between pointer and integer
min.c:18: warning: pointer/integer type mismatch in conditional expression
[static assert]
  [int, unsigned int]
min.c:20: error: size of array ‘type name’ is negative
  [int, double]
min.c:21: error: size of array ‘type name’ is negative
  [int, pointer]
min.c:22: error: size of array ‘type name’ is negative
min.c:22: warning: comparison between pointer and integer
min.c:22: warning: pointer/integer type mismatch in conditional expression

So compared to the traditional type checks:
a) this gives a hard compile error, whereas the existing check would only produce warnings
b) the existing min happily combines (int,unsigned) giving unsigned and (int, double) giving double; the new code will will reject such code.

I think the feature is somewhat desirable; I agree code combining different types in MIN or MAX is flawed - if it is intentional, asking for an explicit cast is not asking too much.

The only downside of the patch is that it uses a language extension. We should strive to reduce usage of language extensions, not increase it.

I also have a personal dislike of fanciness in code. Code should be clean, not cute.
History
Date User Action Args
2012-08-03 12:15:21loewissetrecipients: + loewis, pitrou, vstinner
2012-08-03 12:15:20loewissetmessageid: <1343996120.86.0.149995813205.issue15530@psf.upfronthosting.co.za>
2012-08-03 12:15:20loewislinkissue15530 messages
2012-08-03 12:15:19loewiscreate