
Andre Merzky wrote:
Quoting [Ceriel Jacobs] (Feb 20 2009): (who quoted Steve Fisher)
The user can also create a context with a type known to him and to the implementation. He may need to set attributes of this context before it can be used. The implementation must not modify any attributes - though the constructor may set attributes to sensible defaults which can then be modified by the user.
The set_defaults call should *not* be in the spec - it is purely an implementation thing. I think I agree with that. It is a pity that the Context constructor has a default value "" for the context type. IMHO, the Type attribute should only have read access and be set by the Context constructor, which should then also call set_defaults, which then does not have to be in the API.
Calling set_defaults() in the c'tor breaks. That was actually in the spec at some point, but:
saga::context c ("globus"); c.set_attribute ("UserProxy", "/tmp/non-default-proxy.x509"); c.set_defaults ();
Well, calling set_defaults in the constructor IS in the specs, at least it is in the 1.0 version, which is still the official version, is it not? There, it sais in the Notes: if a type is given, then the CONSTRUCTOR internally calls set_defaults().
The c'tor would throw NoSuccess if no default globus proxy exists. Then, how would you create a globus context which points to a non-default proxy location, like above?
I don't know that the c'tor would throw NoSuccess. Maybe a default UserProxy file does not exist, but is set_defaults() the right time to check? In that case, there is a problem with at least some of the examples in the SAGA specs, see the example on the first page of the "Saga Context Management" paragraph.
Yes, one could argue if an empty type on context creation makes sense, or if one should mandate a valid string. Given that an empty string is a 'valid' string in most languages, that is not much different from other invalid strings like 'klopus'. We have defined error conditions for calling set_defaults() on invalid context attributes. I don't think that this is a big problem at the moment?
I guess there is a difference between "" and "klopus" in that "" is IMHO supposed to mean that the Type is not yet specified, whereas "klopus" specifies a Type, on which the constructor will call set_defaults(), which will probably cause an exception. Cheers, Ceriel