Hacker News new | past | comments | ask | show | jobs | submit login

Compilers are typically not going to waste time looking for very complex, special case patterns which occur rarely (and are usually confounded by various considerations that have to be checked).

For this we need programmable languages in which users can code their own optimization cases.

There is such a thing as "I would like a certain optimization, that should not be upstreamed into the compiler".

That's exactly what's in this article.

The construct:

  HashSet::from([a, b]).contains(&c);
has some definite AST pattern (or can be made to have one with a sufficiently pinned-down language). We can think about adding a pattern match for that AST pattern to the compiler, along with a right hand side to rewrite it into.



Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact