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

Build nested gadgets/sub-circuits consistently #23

Open
AntoineRondelet opened this issue Jul 27, 2020 · 1 comment
Open

Build nested gadgets/sub-circuits consistently #23

AntoineRondelet opened this issue Jul 27, 2020 · 1 comment
Labels
arithmetic-circuit/R1CS Task related to the R1CS programs c++ Task related to the c++ part of the code base code-quality Task related to the code quality (refactor, enhancements etc.)

Comments

@AntoineRondelet
Copy link
Contributor

As mentioned in #19 (comment) let's be consistent with how nested gadgets are instantiated.

@dtebbs
Copy link
Contributor

dtebbs commented Jul 28, 2020

I would be in favour of simply avoiding shared_ptr unless absolutely necessary. The disadvantages I see in using it where not strictly necessary are:

  • It encourages classes which can be left in an uninitialized state, which increases the risk of mysterious runtime bugs. Where possible, it should only be possible to construct classes that are fully initialized / allocated. It makes it more difficult to misuse variables that are in scope.
  • Unnecessary pointers creates more allocation and freeing, and memory fragmentation

In may cases, we need to use pointers of some kind. shared_ptr may sometimes be the right solution, although there are cases where another type might be safer (especially where the sub-gadget is intended to be internal to the gadget that creates it).

@AntoineRondelet AntoineRondelet added arithmetic-circuit/R1CS Task related to the R1CS programs c++ Task related to the c++ part of the code base code-quality Task related to the code quality (refactor, enhancements etc.) labels Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arithmetic-circuit/R1CS Task related to the R1CS programs c++ Task related to the c++ part of the code base code-quality Task related to the code quality (refactor, enhancements etc.)
Projects
None yet
Development

No branches or pull requests

2 participants