Is it common practice to return records from query functions? If not, what are the disadvantages?
Let's say I have a query service that can return some cars and they are currently handed over or not.
My record for a car looks something like this:
-type rent_state:: rented | available.
-record(car, {make::string(), year::integer(), color::string(), state::rent_state()}).
If I then had a request for cars, is it wise to do this to return this record?
-type car::#car{}.
-spec cars() -> [car()].
or should I create a tagged type instead?
-type car()::{ {make, string()}, {year,integer()}, {color,string()}, {state,rent_state()}}).
I want to make an API that is nice to use for others. Any advice is appreciated.
source
share