Zbigniew Lukasiak wrote:
It seems that in the Moose terminology a Type is just a constraint
with a name.  This is different from other languages where the type of
a value does not change in time or in relation to the whole system.
You can copy the value and be sure that the copy has the same type you
can wait and check the value after some time and it's type would not
change, but if a value type is defined by it passing a constraint -
then these invariants do not hold.  For example think about a
constraint that checks if a date is in the past.

This is not to criticise this - I understand that it is just a
practical solution - I just want to know if there is a consensus that
it is OK to write Moose types like DateInThePast.

In some languages a type is mostly just a named set of values, and so it is valid for the same value to belong to more than one type. You see this in Perl 6 for example; when you define a subtype (eg, UInt is subtype of Int where ...) or a union type (eg, Scalar is union of Num|Str etc) values falling under those still belong to their original types but also to the new ones. That said, even in those cases a value would still have just a single "root type", which is the type whose declaration allowed you to select (or "construct") that value in the first place, and any other types would not be re-introducing the value but just using it. -- Darren Duncan

Reply via email to