Value ports in Bolt 2 will support type hinting, that is, users will be able to specify a more specific type descendant than the initial port definition.
Inspector Display
Port type hinting is particularly useful to avoid using a literal unit for object input ports. For example, on the Debug.Log unit, type hinting the Message port from Object to String will display the inline string inspector inline and provide string contextual options when dragging a new connection from that port.
Value Input Hinting
Hinting a value input type will have the following impacts:
- In Live Runtime, it will ensure the conversion happens early through ConversionUtility, which may have marginal performance benefits
- In Generated Runtime, it will allow us to avoid ConversionUtility altogether by knowing the source and destination types at generation time
Value Output Hinting
Hinting a value output type will have the following impacts:
- In Generated Runtime, it will also downcast the output directly with a (cast) operator, allowing us to avoid ConversionUtility. This is a behaviour that is not as “smart”, but it is the only way to determine the types early and avoid conversion.
- In Live Runtime, we will need to match that behaviour by either reworking ConversionUtility to only allow cast operators, or creating a CastUtility.