I was wondering what the proper idiom would be for wrapping C++ functions
that contain a number of optional parameters. For instance:

bool write (const std::string &filename,
             const std::string &fileformat = std::string(),
             ProgressCallback progress callback=NULL)

Is it preferable to expose this in Go as a single function, where the user
would always have to pass the full set of values:

func Write(filename, fileformat string, progress ProgressCallback) bool

Write("foo.jpg", "", nil)
Write("foo", "jpg", nil)
Write("foo", "jpg", myCallback)

Or should it be broken out into explicit Write* calls:

func Write(filename string) bool
func WriteFormat(filename, fileformat string) bool
func WriteFormatCallback(filename, fileformat string, progress
ProgressCallback) bool

This is a smaller example. There are functions that contain 1 required and
4 optional. So I could end up with a number of variants of the call vs one
where they have to pass in at least zero value params.

You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 5 | next ›
Discussion Overview
groupgolang-nuts @
postedApr 19, '14 at 8:52p
activeApr 21, '14 at 11:08a



site design / logo © 2021 Grokbase