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

ppx: qualify usages of stdlib infix operators #11

Merged
merged 4 commits into from
Aug 27, 2024
Merged

Conversation

jchavarri
Copy link
Member

No description provided.

Copy link
Member

@davesnx davesnx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much needed PR

Copy link
Collaborator

@andreypopp andreypopp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the cases where type is already known — I'd use type specific equality operator — e.g. Stdlib.Int.equal for int and so on

By the way not should also be qualified.

@jchavarri
Copy link
Member Author

jchavarri commented Aug 26, 2024

for the cases where type is already known — I'd use type specific equality operator — e.g. Stdlib.Int.equal for int and so on

I'm not sure, this will be adding more runtime without a lot of benefits, see example in playground:

let foo (a: string) (b: string) = Js.log (a = b)
let foo2 (a: string) (b: string) = Js.log (String.equal a b)

produces:

function foo(a, b) {
  console.log(a === b);
}

function foo2(a, b) {
  console.log(Stdlib__String.equal(a, b));
}

@andreypopp
Copy link
Collaborator

I'm not sure, this will be adding more runtime without a lot of benefits, see example in playground

wow, didn't know that, then it's good as it is, thank you!

@jchavarri
Copy link
Member Author

By the way not should also be qualified.

Done in d2f8497.

@anmonteiro
Copy link
Member

for the cases where type is already known — I'd use type specific equality operator — e.g. Stdlib.Int.equal for int and so on

I'm not sure, this will be adding more runtime without a lot of benefits, see example in playground:

let foo (a: string) (b: string) = Js.log (a = b)
let foo2 (a: string) (b: string) = Js.log (String.equal a b)

produces:

function foo(a, b) {
  console.log(a === b);
}

function foo2(a, b) {
  console.log(Stdlib__String.equal(a, b));
}

oh interesting. I think this is because String.equal is a external .. in the .ml but a val in the .mli.

@jchavarri jchavarri merged commit c9e9b4e into main Aug 27, 2024
7 checks passed
@jchavarri jchavarri deleted the ppx-qualify-infix-ops branch August 27, 2024 10:18
@andreypopp
Copy link
Collaborator

oh interesting. I think this is because String.equal is an external .. in the .ml but a val in the .mli.

@anmonteiro should we fix this?

@anmonteiro
Copy link
Member

oh interesting. I think this is because String.equal is an external .. in the .ml but a val in the .mli.

@anmonteiro should we fix this?

I think it's a good idea -- I'll play with it

jchavarri added a commit to jchavarri/opam-repository that referenced this pull request Aug 28, 2024
avsm pushed a commit to avsm/opam-repository that referenced this pull request Sep 5, 2024
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

Successfully merging this pull request may close these issues.

4 participants