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

Use @ instead of % as % is already an operator #289

Closed
Mike96Angelo opened this issue Jan 22, 2023 · 4 comments
Closed

Use @ instead of % as % is already an operator #289

Mike96Angelo opened this issue Jan 22, 2023 · 4 comments

Comments

@Mike96Angelo
Copy link

Mike96Angelo commented Jan 22, 2023

Since % is the modulus operator I think it we be better to use a different symbol, perhaps @

let even = 8 |> @ % 2 === 0;  // 8 % 2 === 0

In some other programming languages that have the pipe operator they support piping is both directions:

let a = 3
  |> square(@)
// let a = square(3)
  
let b = square(@) 
  <| 2
// let b = square(2)

There is some confusion if both are use in the same expression:

let a = 1 |> add(@, @) <| 2
// let a = add(1, 2) or is it  add(2, 1)

to get over this confusion we can add the corresponding < or > to the @

let a = 1 |> add(@>, <@) <| 2
// let a = add(1, 2) no more confusion 

let a = 1 |> add(<@, @>) <| 2
// let a = add(2, 1) no more confusion 
@ljharb
Copy link
Member

ljharb commented Jan 22, 2023

How does that interact with decorators?

@Mike96Angelo
Copy link
Author

Mike96Angelo commented Jan 22, 2023

Since decorators require two arguments @<expression that results in a decorator function> <thing to decorate> we can determine that an @ that receives no arguments that follows a |> can be treated as an injection point instead of a decorator.

if we allow directional piping and use directional injection points (@>, <@) there is no conflict with decorators at all.

@MeguminSama
Copy link

@ has been excluded as a topic reference, noted here:
#232 (comment)
#91 (comment)

@bogdanbiv
Copy link

Please close this issue, as it was cleared in the previous comment.

@nicolo-ribaudo nicolo-ribaudo closed this as not planned Won't fix, can't repro, duplicate, stale Aug 5, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants