Open tebeka opened 4 years ago
Maybe use functional options
These option structs are C++ structs, they have a static Defaults function that
returns a struct (not pointer). When creating an arrow::csv::Reader
you need
to pass options by reference.
cgo can’t work directly with C++, which means we can use them directly as
C.ParseOptions
.
A C function that will get all the parameters for an options struct and create it.
Have C wrappers that will create a pointer to options struct and have setters.
Have a C struct that will be a copy of the C++ struct. Can be used directly from Go and passed around by value.
Use swig to generate wrappers.
1: If you have a procedure with 10 parameters, you probably missed some. - Alan Perlis
@yonidavidson Care to weigh in on the above?
This can be a good POC for SWIG, yet I don't think SWIG will be our silver bullet so It might not be worth to add complexity to our system with it. I think a functional API is a good choice, it gives you an ability to have a good default and to expose the parameters in a need to have way (easy to extend).
I'll probably go with C shadow struct
for now. I'll defer SWIG for when we go all-in on it.
The arrow CSV package has the following options:
ReadOptions
,ParseOptions
&ConvertOptions
. Expose them to Go.