Skip to main content

Questions tagged [type-conversion]

Use for questions about design and implementation of language features converting values between data types. Do not use merely for questions about programming tasks where type conversion is required.

Filter by
Sorted by
Tagged with
3 votes
1 answer
323 views

Why is type-punning at compile-time a no-go?

More on the topic of type-punning being problematic: C23 added constexpr and new rules as to how compile-time constants can be created and handled. We can now ...
CPlus's user avatar
  • 8,301
4 votes
1 answer
319 views

Determining the most optimized data type for the platform with type inference

For my programming language, I have built an engine that goes after the parser and before the compiler. This engine analyzes, validates, and simplifies the AST. During the analasys, it determines as ...
Hg0428's user avatar
  • 173
18 votes
3 answers
2k views

What optimizations does the strict aliasing rule facilitate?

This question is tangentially related to: Why is type reinterpretation considered highly problematic in many programming languages? Regardless how 'problematic' type reinterpretation is, why do some ...
CPlus's user avatar
  • 8,301
6 votes
4 answers
455 views

Pros and cons of user-defined implicit casting

Many languages that has static typing or type hinting, support user-defined casting functions that are called automatically when a function expects another type that the parameter could be cast into. ...
user23013's user avatar
  • 2,430
14 votes
4 answers
3k views

What are the pitfalls of indirect implicit casting?

Many languages that has static typing or type hinting, support user-defined casting functions that are called automatically when a function expects another type that the parameter could be cast into. ...
user23013's user avatar
  • 2,430
15 votes
5 answers
3k views

Why is type reinterpretation considered highly problematic in many programming languages?

C++ disallows reinterpret_cast from int to float as far as I know, and using a ...
CPlus's user avatar
  • 8,301
4 votes
1 answer
220 views

Implementing a number to string semantics efficiently in a C-style language?

In C our options for converting numbers to strings and adding them to a string are limited to: Write your own function. sprintf() to a buffer. Either way, one ...
CPlus's user avatar
  • 8,301