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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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:
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
swift × 4language-design × 1
types × 1
standard-library × 1
functional-programming × 1
integers × 1
type-conversion × 1
literals × 1
inheritance × 1
type-safety × 1
abi-stability × 1