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
Due to the reason of the optional parameter its value required of the primitive type constant value, so that there is no way for using non-primitive value as the optional parameter its default value. So that this example code will throw the compiler error:
But if assuming that we have define the CType implicit conversion for our non-primitive type creates from a primitive type value, then is there any possible to apply this implicit conversion on the optional parameter?
For example, we have creates a CType implicit conversion for type Padding convert from String type, so that we can using a constant string value padding: 100px 100px 100px 100px; as its optional parameter default value:
Due to the reason of the optional parameter padding its default value is a string and this string value is also constant, so that this will not violate the rule of the optional parameter should be constant. and this default value can be stored in the compiled assembly as meta data as other optional parameter does.
This new feature will makes the VisualBasic coding more convenient when the function have a lot of the optional parameter.
The text was updated successfully, but these errors were encountered:
I not sure how the constant optional parameter default value works in the compiler, but is there any possible that if the compiler detected that user have defined an implicit CType operator for the specific type from the primitive type, then compiler will match target type with the primitive type in the meta data?
In my opinion, if the constant string its value is invalid (The compiler will try running the test on this CType operator using the optional parameter its default value before the compilation process, if the test fail, in other words, this operator test throws exception by using a constant value from the optional parameter), then the compiler should throw a compiler error, and stop the compilation process. Due to the reason of the optional parameter its default value is constant, so that this error is very easy to fix and detected, or user can disable it, just like the mechanism of the compiler it does on the Integer overflow checks.
Due to the reason of the optional parameter its value required of the primitive type constant value, so that there is no way for using non-primitive value as the optional parameter its default value. So that this example code will throw the compiler error:
But if assuming that we have define the
CType
implicit conversion for our non-primitive type creates from a primitive type value, then is there any possible to apply this implicit conversion on the optional parameter?For example, we have creates a
CType
implicit conversion for typePadding
convert fromString
type, so that we can using a constant string valuepadding: 100px 100px 100px 100px;
as its optional parameter default value:Due to the reason of the optional parameter
padding
its default value is a string and this string value is also constant, so that this will not violate the rule of the optional parameter should be constant. and this default value can be stored in the compiled assembly as meta data as other optional parameter does.This new feature will makes the VisualBasic coding more convenient when the function have a lot of the optional parameter.
The text was updated successfully, but these errors were encountered: