Conversions revamped #11284
Labels
high impact
Changes are very prominent and affect users or the project in a major way.
language design
Any changes to the language, e.g. new features
medium effort
Default level of effort
must have
Something we consider an essential part of Solidity 1.0.
needs design
The proposal is too vague to be implemented right away

Currently we support (an ever shrinking number of) implicit type conversions and some explicit ones. The explicit conversions mostly truncate/extend, and only a single one (integer to enum) is performing a check and panic.
During #9170 we have endlessly debated whether converting from a larger bytes should truncate or throw a panic, and finally realised we may want to review how conversions work in general. It seems that we want to make in any way ambiguous conversions explicitly understandable.
In the past we discussed new casting/conversion syntax here and here:
To summarise, the following syntactical ideas were proposed:
cast<to>(from)
convert<to>(from)
from.as<to>()
cast<intermediate1,intermediate2,final>()
(in case of a series of conversions)bytes32.truncateFrom(<dynamic bytes>)
truncate<..>()
extend<..>()
On todays design call there seemed consensus to rather have explicitly understandable function names (such as
truncate
andextend
), instead of a genericcast
.(Moved from #9170 (comment))
The text was updated successfully, but these errors were encountered: