I do not understand at all author's statement that OCaml datastructures are big win over Python's
let {cache; config} = b in
print_endline (String.concat "," cache);
print_endline (String.concat "," config)
;;
vs, actually I'm not even sure what the ocaml is attempting, some variation of
print '%s,' % b.cache
print '%s,' % b.config
Which, in Python, if your printing more than a few should be
print ',\n'.join((b.config, b.cache, b.data))
Or if want all fields and they are in correct order
print ',\n'.join(b)
>> The syntax [of NamedTuples] isn’t great, though, and you can’t do pattern matching on the names, only by remembering the order:
Other than misuse of term "pattern matching", that statement is true and is trivially overcome with two line function, one line lambda, or once and for all by subclassing NamedTuple. Here's the function variant:
def GimmieThing(keyword args in any order)
return ThingNamedTuple(args in correct order)
Other than misuse of term "pattern matching", that statement is true and is trivially overcome with two line function, one line lambda, or once and for all by subclassing NamedTuple. Here's the function variant: