Closed philpax closed 2 years ago
:+1: - this is how I wrote my actual code too, it seems like the right way to me.
The difference between a local macro and the lambda here is that the macro can "capture" the graph
variable by borrowing at every invocation, unlike the closure which would borrow it for its whole lifetime. That's why the lambdas need the graph
as an additional argument, to keep the same borrowing semantics.
That said, it may be clearer to avoid macros for this, and a single extra parameter on every call doesn't sound that bad. I'm open to a change like this if it makes the example clearer :)
I'm a bit short on time, but I would happily accept a PR for this :+1:
Hey there! I'm building off the example to work for my use case, and I noticed you're using macros to construct the node parameters:
I'd suggest using lambdas, because they're easier to parameterise and (in my opinion) cleaner: