Skip to content

feat(api/iota): endofunctors#1191

Open
poolcritter wants to merge 2 commits into
FallingColors:mainfrom
poolcritter:push-nvtvkvszxopq
Open

feat(api/iota): endofunctors#1191
poolcritter wants to merge 2 commits into
FallingColors:mainfrom
poolcritter:push-nvtvkvszxopq

Conversation

@poolcritter

Copy link
Copy Markdown

adds visit and visitChildren to iotas letting you apply a UnaryOperator to an entire tree of them. this is like hexal's IMappableIota except I don't know if that does self pre or post (or if it does self at all). awa.

I haven't tested this in prod; hex doesn't have anything that would use this yet. @IridescentVoid I believe you have a patch that may want to use this?

Cc: @IridescentVoid
Change-Id: Ic464f4702ba9b0379c93e31723e2a5fe6a6a6964
Issue: closes #1083

@IridescentVoid IridescentVoid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

github ate the comment I left on the file. see review below instead.

@github-project-automation github-project-automation Bot moved this from 📋 Backlog to 🏗 In progress in Hex Casting Jul 8, 2026

@IridescentVoid IridescentVoid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code-Review: -1

Implementation of visitChildren should be made more readable. I would like to at least see full-length variable names.

I'd also like feedback from others on the API design since changing this later would be a breaking change.

Comment thread Common/src/main/java/at/petrak/hexcasting/api/casting/iota/ListIota.java Outdated
@IridescentVoid IridescentVoid added enhancement New feature or request 1.20 api API-related enhancements/bugs/optimizations labels Jul 8, 2026

@Override
protected Iota visitChildren(UnaryOperator<Iota> visitor) {
var out = new ArrayList();

@IridescentVoid IridescentVoid Jul 9, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var out = new ArrayList();
var out = new ArrayList<Iota>();

Other than this, looks good to merge if there are no other comments on the api design. Not good to merge, I'm pretty sure the logic is wrong.

@IridescentVoid IridescentVoid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code-Review: -1

Noticed a pretty major logic bug that I somehow missed during the initial review pass. We should probably test this more throughly before merging.

Request on using ArrayList<Iota> still applies.

var out = new ArrayList();
boolean conserve = true;
for (Iota orig : getList()) {
var replacement = visitor.apply(orig);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var replacement = visitor.apply(orig);
var replacement = orig.visit(visitor);

Change-Id: I6f4fdb764e727fa211db96140ba2b6f26a6a6964
adds `visit` and `visitChildren` to iotas letting you apply a
UnaryOperator to an entire tree of them. this is like hexal's
IMappableIota except I don't know if that does self pre or post (or if
it does self at all). awa.

I haven't tested this in prod; hex doesn't have anything that would use
this yet. @IridescentVoid I believe you have a patch that may want to
use this?

Cc: @IridescentVoid
Change-Id: Ic464f4702ba9b0379c93e31723e2a5fe6a6a6964
Issue: closes FallingColors#1083
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.20 api API-related enhancements/bugs/optimizations enhancement New feature or request

Projects

Status: 🏗 In progress

Development

Successfully merging this pull request may close these issues.

feat: add an iota walker / endofunctor method

3 participants