Skip to main content
38 votes

When can widening conversions cause problems?

In what cases could allowing them impact program correctness? I used to work at Coverity, which makes program analysis tools seeking to identify code containing bugs that are (1) plausibly created by ...
Eric Lippert's user avatar
  • 6,757
9 votes
Accepted

Why color literals?

Colour literals are unusual, but not rare, in recent languages. The obvious case of them is languages like HTML and CSS, where colour is a core presentational facet and there are several styles of ...
Michael Homer's user avatar
  • 15.3k
6 votes

Why color literals?

You immediately see the effect a change would have; while I can guess the approximate color given a set of RGB values, it's better to have a visual confirmation. The color picker allows to save a ...
Glorfindel's user avatar
  • 1,523
3 votes

When can widening conversions cause problems?

If a program performs an operation like int1 = long1*long2;, the operation may be seen as performing the following sequence of steps: Convert ...
supercat's user avatar
  • 2,312
3 votes

When can widening conversions cause problems?

In Tyr, both implicit conversions are not allowed. There isn't even a warning, they types are just viewed as distinct. The rationale behind this was that even when working just with integers, if ...
feldentm's user avatar
  • 2,418
3 votes
Accepted

How to avoid hidden performance problems in functional interfaces?

Documentation & Culture Firstly performance footguns are better avoided if the standard library documents the algorithmic complexity of its functions. This of course does not immediately help you ...
Bruce Adams's user avatar
  • 3,002
2 votes

When can widening conversions cause problems?

Eric Lippert's answer mentions "late widening conversions" as a source of bugs, i.e. those where the implicit conversion occurs later than the programmer expects. A less common but also ...
kaya3's user avatar
  • 22.4k
1 vote

When can widening conversions cause problems?

On dynamic typed languages, widening (and narrowing) is somewhat expected to occur, as some operations can change the value type. It's common, for example, that exceeding some ...
André L F S Bacci's user avatar
1 vote

How could a language support adding new types to the middle of the inheritance tree in an ABI-stable way?

I have recently had an idea. For the purpose of this explanation, let's consider a simpler set of protocols, and a type that adopts both: ...
Bbrk24's user avatar
  • 9,672

Only top scored, non community-wiki answers of a minimum length are eligible