opticstyles: to be or not to be #142
Draft
+44
−101
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was curious to see what Accessors would look like without
OpticStyle
at all. There's certain benefit, even aside from code reduction and simplification.Currently, if an optic
O
can performset()
, it needs to beSetBased
. This means,modify()
on a composed optic includingO
will also callset
, even ifmodify(O)
can be defined and is more performant, for example. This is just because of opticstyle resolution.As I understand, opticstyles were introduced mostly to work around Julia compilation limitation. This was quite long ago, so maybe we are becoming ready to get rid of them?
Tests on this PR should pass, but this required me to use
@eval
in the same manner as we did forgetall/setall
. The second-to-last commit has the same functionality but without@eval
. Interestingly, it passes all tests on Julia nightly (aplavin@66aa453)! But not on actual releases...For now, this is just an experiment. But would be nice to track whether Julia compilation/inference steadily improves like that, making some hacks from the past less relevant.