-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Required and Optional parameters in initialiser #561
Comments
Use |
You can compile an Initialiser with no default argument for an And further, if an I was also able to construct an Initialiser without providing a value for a |
If unspecified, default constructor is used. In case of
True, but it is a lot easier to miss a required parameter if doesn't have an explicit keyword in front of it.
Parameters are checked when the generic initialiser is casted to its specialised counterpart. This normally only takes place when you initialize a class with it. All initialisers in python are generic so they won't throw errors until you use them to initialise the class they are meant for. |
I have the feeling we should make the default argument explicit and not rely on a default constructor. And then all parameters without default argument are required to be set by a user. Well, the |
This is a minimal example example_ik_p2l.py.txt that defines a p2l_map = \
('exotica/PointToLine', {
'Name': p2l_name,
'EndEffector': [end_effector],
# 'EndPoint': "0.5 0.5 0", # this is a 'Required' parameter
}) without the required |
I think you uncovered a quite significant bug for when initialised from a Python tuple/dict or C++ map - but not from XML. So the true question is: Why did If we look in the generated virtual void Check(const Initializer& other) const
{
if(!other.HasProperty("Name") || !other.properties_.at("Name").IsSet()) ThrowPretty("Initializer PointToLineInitializer requires property Name to be set!");
if(!other.HasProperty("EndPoint") || !other.properties_.at("EndPoint").IsSet()) ThrowPretty("Initializer PointToLineInitializer requires property EndPoint to be set!");
} I think in this case the |
The initialiser definition supports
Required
andOptional
parameters.What is the intended behaviour of those?
The
Optional
can be used with and without default argument (set via=
).Required
on the other hand does not support default arguments but the Initializer can be constructed without providing an argument value, in which case it is using random memory.I think the
Required
andOptional
properties should be implicitly defined by a default argument:=
, the parameter isOptional
Required
and the initialiser should throw an error if no argument is provided.The text was updated successfully, but these errors were encountered: