Hi all, here is another question about the C++ language binding we stukmbled upon. The API spec says that the session is an optional argument to each object creation in SAGA. If the session is not given, a default session (theSession) is to be associated with the object. Now, consider a object which has a number of optyional parameters already (example not spec conform): saga::file (string url, mode=saga::file::mode::RO, saga::session s); If a programmer wants to specify a session, he NEEDS to specify mode, and all other optional parameters of the constructor. For a programmer who always specifies a session that is awkward. OTOH, a constructor like saga::file (saga::session s, string url, mode=saga::file::mode::RO); would giove that programmer the ability to use session and rely on parameters defaults, but for another programmer who does not use an explicit session it would require to ALWAYS specify the session anyway: saga::file f (theSession, url); The solution we would like to propose is to introduce two versions of all constructors: saga::file ( string url, mode=saga::file::mode::RO); saga::file (saga::session s, string url, mode=saga::file::mode::RO); which would accomodate both use cases nicely. To be sure: that affects only the C++ language bindings - that might look totally different for other languages. Any comments? If not, we go for the proposed solution... Cheers, Andre. -- +-----------------------------------------------------------------+ | Andre Merzky | phon: +31 - 20 - 598 - 7759 | | Vrije Universiteit Amsterdam (VU) | fax : +31 - 20 - 598 - 7653 | | Dept. of Computer Science | mail: merzky@cs.vu.nl | | De Boelelaan 1083a | www: http://www.merzky.net | | 1081 HV Amsterdam, Netherlands | | +-----------------------------------------------------------------+
That's what I was assuming would happen, so I'd say go ahead. Tom On Fri, 4 Nov 2005, Andre Merzky wrote:
Hi all,
here is another question about the C++ language binding we stukmbled upon. The API spec says that the session is an optional argument to each object creation in SAGA. If the session is not given, a default session (theSession) is to be associated with the object.
Now, consider a object which has a number of optyional parameters already (example not spec conform):
saga::file (string url, mode=saga::file::mode::RO, saga::session s);
If a programmer wants to specify a session, he NEEDS to specify mode, and all other optional parameters of the constructor. For a programmer who always specifies a session that is awkward.
OTOH, a constructor like
saga::file (saga::session s, string url, mode=saga::file::mode::RO);
would giove that programmer the ability to use session and rely on parameters defaults, but for another programmer who does not use an explicit session it would require to ALWAYS specify the session anyway:
saga::file f (theSession, url);
The solution we would like to propose is to introduce two versions of all constructors:
saga::file ( string url, mode=saga::file::mode::RO); saga::file (saga::session s, string url, mode=saga::file::mode::RO);
which would accomodate both use cases nicely. To be sure: that affects only the C++ language bindings - that might look totally different for other languages.
Any comments? If not, we go for the proposed solution...
Cheers, Andre.
Andre Merzky wrote:
here is another question about the C++ language binding we stukmbled upon. The API spec says that the session is an optional argument to each object creation in SAGA. If the session is not given, a default session (theSession) is to be associated with the object.
Now, consider a object which has a number of optyional parameters already (example not spec conform):
saga::file (string url, mode=saga::file::mode::RO, saga::session s);
If a programmer wants to specify a session, he NEEDS to specify mode, and all other optional parameters of the constructor. For a programmer who always specifies a session that is awkward.
OTOH, a constructor like
saga::file (saga::session s, string url, mode=saga::file::mode::RO);
would giove that programmer the ability to use session and rely on parameters defaults, but for another programmer who does not use an explicit session it would require to ALWAYS specify the session anyway:
saga::file f (theSession, url);
The solution we would like to propose is to introduce two versions of all constructors:
saga::file ( string url, mode=saga::file::mode::RO); saga::file (saga::session s, string url, mode=saga::file::mode::RO);
which would accomodate both use cases nicely. To be sure: that affects only the C++ language bindings - that might look totally different for other languages.
Any comments? If not, we go for the proposed solution...
What about using the Boost.Parameters library to have true named parameters in C++: saga::file f("url", session=theSession, mode=saga::file::mode::RO); or saga::file f("url", mode=saga::file::mode::RO); etc. ? Regards Hartmut
On Fri, Nov 04, 2005 at 02:30:39PM -0600, Hartmut Kaiser wrote:
What about using the Boost.Parameters library to have true named parameters in C++:
Mandating anything beyond standard C++ sounds like a bad idea to me... Thilo -- Thilo Kielmann http://www.cs.vu.nl/~kielmann/
Thilo Kielmann wrote:
On Fri, Nov 04, 2005 at 02:30:39PM -0600, Hartmut Kaiser wrote:
What about using the Boost.Parameters library to have true named parameters in C++:
Mandating anything beyond standard C++ sounds like a bad idea to me...
Good point. Regards Hartmut
The double constructor seem OK to me. Thilo On Fri, Nov 04, 2005 at 02:12:38PM -0600, Andre Merzky wrote:
X-Original-To: kielmann@localhost Delivered-To: kielmann@localhost.cs.vu.nl Delivered-To: grdfm-saga-rg-outgoing@mailbouncer.mcs.anl.gov X-Original-To: grdfm-saga-rg@mailbouncer.mcs.anl.gov Delivered-To: grdfm-saga-rg@mailbouncer.mcs.anl.gov Date: Fri, 4 Nov 2005 14:12:38 -0600 From: Andre Merzky
To: Simple API for Grid Applications WG Subject: [saga-rg] C++ binding: question X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mailbouncer.mcs.anl.gov X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mailbouncer.mcs.anl.gov Hi all,
here is another question about the C++ language binding we stukmbled upon. The API spec says that the session is an optional argument to each object creation in SAGA. If the session is not given, a default session (theSession) is to be associated with the object.
Now, consider a object which has a number of optyional parameters already (example not spec conform):
saga::file (string url, mode=saga::file::mode::RO, saga::session s);
If a programmer wants to specify a session, he NEEDS to specify mode, and all other optional parameters of the constructor. For a programmer who always specifies a session that is awkward.
OTOH, a constructor like
saga::file (saga::session s, string url, mode=saga::file::mode::RO);
would giove that programmer the ability to use session and rely on parameters defaults, but for another programmer who does not use an explicit session it would require to ALWAYS specify the session anyway:
saga::file f (theSession, url);
The solution we would like to propose is to introduce two versions of all constructors:
saga::file ( string url, mode=saga::file::mode::RO); saga::file (saga::session s, string url, mode=saga::file::mode::RO);
which would accomodate both use cases nicely. To be sure: that affects only the C++ language bindings - that might look totally different for other languages.
Any comments? If not, we go for the proposed solution...
Cheers, Andre.
-- +-----------------------------------------------------------------+ | Andre Merzky | phon: +31 - 20 - 598 - 7759 | | Vrije Universiteit Amsterdam (VU) | fax : +31 - 20 - 598 - 7653 | | Dept. of Computer Science | mail: merzky@cs.vu.nl | | De Boelelaan 1083a | www: http://www.merzky.net | | 1081 HV Amsterdam, Netherlands | | +-----------------------------------------------------------------+
-- Thilo Kielmann http://www.cs.vu.nl/~kielmann/
participants (4)
-
Andre Merzky
-
Hartmut Kaiser
-
Thilo Kielmann
-
Tom Goodale