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

Make Crystal::Select::When inherit from Crystal::ASTNode #14493

Closed

Conversation

HertzDevil
Copy link
Contributor

This doesn't affect the macro API, because no AST node methods are available on Select yet. It reserves the macro type name SelectWhen though (note the lack of a namespace).

@straight-shoota
Copy link
Member

I find the disparity between Select::When and SelectWhen quite confusing. And then there's also When (for case ... when), which makes me wonder if there's even a need for distinct data types for when in different contexts 🤔

Perhaps an easy solution could be to move Select::When to When?

@HertzDevil
Copy link
Contributor Author

HertzDevil commented Apr 18, 2024

That way you'd always have to remember to write conds.first whenever dealing with select expressions, which might be a tradeoff. But maybe it isn't such a big issue since the compiler has seen wilder reuse of AST node types (e.g. Arg as enum member)

@straight-shoota
Copy link
Member

I suppose a benefit of having distinct types is a smaller memory footprint. There's no need to allocate an array for conds if it can only be one item.

@HertzDevil HertzDevil deleted the refactor/select-when-astnode branch May 14, 2024 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants