Jarek, others,
I kind of like the idea of a property having a type,
but I have a few questions regarding implementation...
In the following...
<property name="a" type="int" value="1234"
/>
<property name="a" value="5678"
/>
If the default type for properties if none is specified
is 'string', then what is the type of 'a' after the two property assignments
above?
<property name="a"
value="${convert::to-int('1234')}" />
Again, if the default property type is 'string', then
what is the type of 'a' after this assignment?
Regarding disallowing all implicit conversions in
operators, I can see why you might want this, but I have a feeling that it will
be more of a source for error than a means for preventing errors... mostly
because it isn't always (often?) going to be apparent by looking at the build
file exactly what a property's type is. I imagine this will lead to people
not using types because of the dangers of inappropriate implicit conversion, or
guarding against implicit conversion by extensively (excessively) using explicit
conversion.
Notwithstanding, "it's possible to
do it without breaking compatibility"... you can't claim this if you are
making a change that turns a previously valid operation into an
error!
Having said the above, there is an alternative to
disallowing implicit type conversion (that unfortunately also breaks backwards
compatibility) that means that all implicit type conversions should be
safe:
I've never been a particular fan of overloading the '+'
operator with string concatenation... if '+' only means addition, then it would
always involve numeric-conversion. Because there is no implicit conversion
from boolean to integer, a boolean operand will cause an error. Conversely
if (for example) '|' means concatenation then it would always involve
(unambiguous) string-conversion.
Would just this last be enough type safety? It
still includes implicit conversion from string to int/float, but in a (IMHO)
safe fashion.
Regards,
-- Troy
|
- [Nant-users] Re: [nant-dev] Typed properties Troy Laurin
- [Nant-users] Re: [nant-dev] Typed properties Jaroslaw Kowalski
- Re: [Nant-users] Re: [nant-dev] Typed propertie... Gert Driesen
- Re: [Nant-users] Re: [nant-dev] Typed propertie... Malcolm MacLucas
- Re: [Nant-users] Re: [nant-dev] Typed prope... Gert Driesen
- Re: [Nant-users] Re: [nant-dev] Typed p... Malcolm MacLucas
- Re: [Nant-users] Re: [nant-dev] Typed p... Ian MacLean
- RE: [Nant-users] Re: [nant-dev] Typed properties Troy Laurin
- [Nant-users] RE: [nant-dev] Typed properties John Ludlow