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

Right-to-left argument application? #1

Open
philbooth opened this issue Mar 31, 2014 · 3 comments
Open

Right-to-left argument application? #1

philbooth opened this issue Mar 31, 2014 · 3 comments

Comments

@philbooth
Copy link

This is probably a terrible idea, but how do you feel about using the << operator to support applying arguments from right-to-left? People would need to parenthesise if they were mixing both operators in one statement (or to keep it simple you could prohibit mixed usage entirely).

In other words:

bar(123) << foo;
// Compiles to bar(foo, 123);
@adlawson
Copy link
Owner

Transcript from our Skype conversation so I don't forget what we said:

Andrew Lawson: I was thinking about using some sort of placeholder to do it, like

foo >> bar(*, 123)

Andrew Lawson: dunno
Phil Booth: ah, cool, that would be much cleaner
Phil Booth: my << idea felt like a complete can of worms as i was writing it down
Andrew Lawson: I dunno, I do quite like your way though
Andrew Lawson: I'll try them both out :)
Phil Booth: the thing is, if you're scanning code quickly, i suspect yours will stand out more
Phil Booth: less errors from misreading
Phil Booth: also, there is plenty scope for some horrific statements if people had a need to mix both
Andrew Lawson: yeah, I see what you mean
Andrew Lawson: I'll try them both out anyway and see what happens

@adlawson
Copy link
Owner

Again, taking pointers from Elixir, I'll likely use the & character by default to reference the input.

foo >> bar(&, 123); // bar(foo, 123);
foo >> bar(123, &); // bar(123, foo);

// Without reference, pushes it onto the end
foo >> bar(123); // bar(123, foo);

I think if it's implemented like this it makes sense to make it possible to add the reference to the middle of the partial.

foo >> bar(1, &, 2, 3); // bar(1, foo, 2, 3);
foo >> bar(1, 2, &, 3); // bar(1, 2, foo, 3);

@philbooth
Copy link
Author

nod-01

Oh yeah, that's heaps better! :)

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

No branches or pull requests

2 participants