fhicl cpp and nil
Consider the fhicl fragment
name : niland the code fragment:
string name = pSet.get<string>)("name");
Last I checked, fhiclcpp happily sets the c++ variable name to the value "nil". I would prefer that, instead, fhicl should throw an exception. That is, it should treat the value nil as a special value, similar to true, false, infinity; the behaviour of the special value should be that it cannot be converted to any type and will always throw
To be more specific, the following should all throw, for all T, if the parameter name has the value nil.
T default; T name = pSet.get<string>)("name"); T name = pSet.get<string>)("name",default); T output; bool what = pSet.get_if_present<T>( "name", output );
We should talk about what happens if I quote nil.
name : "nil"
#2 Updated by Christopher Green almost 7 years ago
- Description updated (diff)
- Category set to Infrastructure
- Status changed from Accepted to Resolved
- Assignee set to Qiming Lu
- Target version set to 1.02.00
- % Done changed from 0 to 100
- Scope set to Internal
- Experiment Mu2e added
- SSI Package fhicl-cpp added
We believe this issue was resolved by Qiming introducing the
@nil keyword in time for the art suite 1.02.00 release. Please note that if the string "nil" is set as you describe, then an attempt to get a string would produce no error, but an attempt to get anything else would produce a (possibly wrapped)