Benjamin Bannier created MESOS-5773:
---------------------------------------
Summary: Bytes and Duration subclasses subvert the type system
Key: MESOS-5773
URL: https://issues.apache.org/jira/browse/MESOS-5773
Project: Mesos
Issue Type: Bug
Reporter: Benjamin Bannier
Priority: Minor
{{Bytes}} and {{Duration}} have a number of subclasses to create quantities
with different units, i.e.,
* {{Bytes}} is specialized as {{Gigabytes}}, {{Kilobytes}}, {{Megabytes}}, and
{{Terabytes}}, and
* {{Duration}} is specialized as {{Days}}, {{Hours}}, {{Microseconds}},
{{Milliseconds}}, {{Minutes}}, {{Nanoseconds}}, {{Seconds}}, and {{Weeks}}.
Effectively all these subclasses do is add multiplicative factors to the
wrapped value. The subclasses are often used interchangeably with their base
class, often involving slicing away type information (which is technically safe
as the subclasses do not contain additional members or functions).
These type hierarchies seem to needlessly complicate the type system. It
becomes e.g., much harder to catch all {{Duration}} types when specializing
templates. It seems that e.g., a factory function {{Seconds}} directly
returning a {{Duration}} would work just as well, but keep the type system
cleaner.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)