HigherOrderCO / Bend

A massively parallel, high-level programming language
https://higherorderco.com
Apache License 2.0
17.48k stars 428 forks source link

Refactor Transform String Resugar Term Scott #714

Closed Liberxue closed 2 months ago

Liberxue commented 2 months ago

713

Liberxue commented 2 months ago

The visitor is completely unnecessary here, doesn't really simplify.

I like the idea of the try_resugar functions, it lets the pattern matching not be repeated twice.

You could have a single build_string function that takes takes the encoding, tries the correct encoded pattern and tries the non-applied constructors, without repetition.

Also, please leave the if tree since it mimics the shape of the AST and is easier for me to visualize the structure.

Done Please review~~thx @developedby

Liberxue commented 2 months ago

This is nicer to read without the visitor, but my other previous comments still apply.

Also, please do the changes on resugar_list as well. It's almost an exact copy of this one, just looking for a slightly different pattern. It would be confusing if they were implemented differently

In the resugar_lists file, after careful reading, I found that extracting code blocks could lead to reduced performance due to cloning. I haven't thought of a better approach at the moment~~~

developedby commented 2 months ago

Can you just run cargo fmt?

Liberxue commented 2 months ago

Can you just run cargo fmt? So Sorry OKK~~ done

developedby commented 2 months ago

Thank you very much for the contribution