Skip to content
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

Create function for EnergyCutSettings #300

Open
Jean1995 opened this issue Jul 22, 2022 · 3 comments
Open

Create function for EnergyCutSettings #300

Jean1995 opened this issue Jul 22, 2022 · 3 comments
Labels

Comments

@Jean1995
Copy link
Member

When creating EnergyCutSettings, one has to explicitly create a shared ptr in C++:

auto cuts = std::make_shared<EnergyCutSettings>(2, 1, false);

There should be a create function this does this, as it is already implemented for other objects as well:

auto cuts = make_energy_cuts(2, 1, false);

@maxnoe
Copy link
Member

maxnoe commented Jul 22, 2022

I dont like this. This reduces the Information available for the Reader for a minimal number of saved character.

@Jean1995
Copy link
Member Author

I dont like this. This reduces the Information available for the Reader for a minimal number of saved character.

Isn't it common to provide such helper function within an API?

@maxnoe
Copy link
Member

maxnoe commented Jul 22, 2022

Isn't it common to provide such helper function within an API?

What is the benefit of writing or reading:

auto cuts = make_energy_cuts(2, 1, false);

over?

auto cuts = std::make_shared<EnergyCutSettings>(2, 1, false);

It's 10 characters shorter, yes. But you loose the type information completely. The second version is completely clear that it creates a std::shared_ptr<EnergyCutSettings>.

Don't optimize the number of typed characters if it hurts something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants