You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently to convert between types there is inconsistency. Methods like toString() and toNumber() exist, but they are not standardized in any way. "Types" such as classes and type interfaces are required to spit out the passed object if it is an instance of the type. This sometimes causes issues with initializers.
A new as keyword would be better. Instead of Type($obj), one would write $obj as Type. It would not be up to the Type to decide what to return. Instead, the keyword will look for two possible means by which the object can be converted:
$obj implements a to method which accepts Type as its type argument.
Type implements a from class function which accepts $obj as its obj argument.
If the object already conforms to the type, the as implementation should spit out the object unchanged, without even checking for conversion methods.
The text was updated successfully, but these errors were encountered:
Currently to convert between types there is inconsistency. Methods like
toString()
andtoNumber()
exist, but they are not standardized in any way. "Types" such as classes and type interfaces are required to spit out the passed object if it is an instance of the type. This sometimes causes issues with initializers.A new
as
keyword would be better. Instead ofType($obj)
, one would write$obj as Type
. It would not be up to the Type to decide what to return. Instead, the keyword will look for two possible means by which the object can be converted:$obj
implements ato
method which accepts Type as itstype
argument.from
class function which accepts$obj
as itsobj
argument.If the object already conforms to the type, the
as
implementation should spit out the object unchanged, without even checking for conversion methods.The text was updated successfully, but these errors were encountered: