rust-unofficial / patterns

A catalogue of Rust design patterns, anti-patterns and idioms
https://rust-unofficial.github.io/patterns/
Mozilla Public License 2.0
7.87k stars 357 forks source link

Interpreter design pattern #211

Closed fade2black closed 3 years ago

fade2black commented 3 years ago

closes #210

pickfire commented 3 years ago

@fade2black Can you please mark this as draft pull request? I don't see any difference.

simonsan commented 3 years ago

Can you please mark this as draft pull request? I don't see any difference.

Good catch, done that now :)

fade2black commented 3 years ago

I could add more on macro_rules!. For example creating DSLs as Interpreter pattern in the Discussion section. But I am not sure whether or not it'll make the chapter too long.

simonsan commented 3 years ago

Is this ready to review? ;)

fade2black commented 3 years ago

@simonsan of course. I'll make changes as I get feedbacks.

simonsan commented 3 years ago

@simonsan of course. I'll make changes as I get feedbacks.

Ok ;-) wasn't sure if it's still WIP hence I thought I'd ask. Will take a look into it today/tomorrow. 👍🏽

fade2black commented 3 years ago

@simonsan decided not to go far without people's feedback :-)

pickfire commented 3 years ago

I personally think the examples are overly complicated.

fade2black commented 3 years ago

@pickfire @MarcoIeni @simonsan I agree, the assembly language may seem to be daunting. I could remove this part. How about simply converting normal (infix) expressions into postfix or prefix expressions? For example, 2 + 3 => 2 3 + or + 2 3. I took this example from GoF. Wikipedia also explains by giving the same examples, but much more simpler. Only two operations + and -.

simonsan commented 3 years ago

@pickfire @MarcoIeni @simonsan I agree, the assembly language may seem to be daunting. I could remove this part. How about simply converting normal (infix) expressions into postfix or prefix expressions? For example, 2 + 3 => 2 3 + or + 2 3. I took this example from GoF. Wikipedia also explains by giving the same examples, but much more simpler. Only two operations + and -.

I think the easier the example, the more broken down to the basics the better for Rustlings the more viable for this repository it is. So for sure, if you think it's easier for people reading your article, a topic change (for the example) might be viable. ;)

fade2black commented 3 years ago

@simonsan Ok, let me simplify it and I'll let you know to review. 🙂

simonsan commented 3 years ago

@simonsan Ok, let me simply it and I'll let you know to review. 🙂

Ok :)

pickfire commented 3 years ago

That seemed better. I have tons of articles in this-week-in-rust.org talking about parsing, some more with different methods. Maybe we can just point them to those articles, those are very detailed step by step guide using specific algorithms.

simonsan commented 3 years ago

That seemed better. I have tons of articles in this-week-in-rust.org talking about parsing, some more with different methods. Maybe we can just point them to those articles, those are very detailed step by step guide using specific algorithms.

You could post them here if they are viable so we can add them to the see also section. But external articles are not really a replacement for examples in our articles, so not sure how much that could make the examples less complicated or something. Or did I understand you wrong?

fade2black commented 3 years ago

@simonsan Ready. You can review.

fade2black commented 3 years ago

@simonsan @pickfire @MarcoIeni If you have anything to add plz let me know.

MarcoIeni commented 3 years ago

The new example was great! Very easy to understand, thank you!

simonsan commented 3 years ago

Thank you for all your contributions @fade2black 👍🏽 <3