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

Implement infix:<x> and infix:<xx> in examples/ #278

Closed
masak opened this issue Feb 25, 2018 · 1 comment
Closed

Implement infix:<x> and infix:<xx> in examples/ #278

masak opened this issue Feb 25, 2018 · 1 comment

Comments

@masak
Copy link
Owner

masak commented Feb 25, 2018

One as a sub, the other as a macro.

I just went and removed these two operators from core 007 on the master branch. Outside of the tests, the documentation, and the self-hosting, we didn't mention these operators at all. Notably, there was not a single use of them in examples/.

But they're highly user-definable, and nothing is lost by defining them this way. In fact, the kind of provide a cute contrast between when you'd use a sub and when you'd use a macro.

(Why is infix:<xx> a macro? Because we want the "thunkish" behavior of for example. my i = 0; my array = i++ xx 3; (assuming postfix:<++> for convenience) should evaluate to [0, 1, 2].)

As #214 points out, it's also quite a good example of an exception to the Single Evaluation Rule — we get the thunkish behavior precisely because we evaluate the left macro operand once per iteration.

@masak
Copy link
Owner Author

masak commented Feb 25, 2018

This is easy, and doable today. As per #194, whoever does this also gets to pick one of the old example source files to remove.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant