Project

General

Profile

Bug #2804

fhicl cpp and nil

Added by Rob Kutschke about 8 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Infrastructure
Target version:
Start date:
06/29/2012
Due date:
% Done:

100%

Estimated time:
Occurs In:
Scope:
Internal
Experiment:
Mu2e
SSI Package:
fhicl-cpp
Duration:

Description

Consider the fhicl fragment

  name : nil
and 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"

Rob

History

#1 Updated by Marc Paterno almost 8 years ago

  • Status changed from New to Accepted

Our solution is to make @nil be the spelling of the magic token that denotes the nil object, so that "nil", 'nil' and nil (unquoted) are all normal strings.

#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) boost::any_cast exception.

#3 Updated by Christopher Green almost 7 years ago

  • Status changed from Resolved to Closed


Also available in: Atom PDF