6 Oct 2011 12:35
Interfaces / data types in E
We've got quite a few methods that take or return maps. e.g.
to purchase(customerDetails :Map[String,any]) {
... customerDetails["name"] ...
...
if (problem) {
notify(customerDetails["email"])
}
...
}
The problem is that it's not obvious from the method signature what keys
need to be present. Often someone fails to include a mapping, and the
system only fails later in some case where it needed that value.
What I think I'd like to do is something like:
def CustomerDetails := makeNamedTuple([
"name" => String,
"email" => String,
])
...
to purchase(customerDetails :CustomerDetails]) {
... customerDetails["name"] ...
}
So that:
(Continue reading)
RSS Feed