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

Begin cleaning up the PPX #534

Merged
merged 2 commits into from
Jan 7, 2018
Merged

Begin cleaning up the PPX #534

merged 2 commits into from
Jan 7, 2018

Conversation

aantron
Copy link
Collaborator

@aantron aantron commented Jan 2, 2018

This commit deprecates a lot of little-used PPX features, which are probably also somewhat ill-conceived. This includes all PPX options and several bits of syntax:

Some more notes:

  • While editing the PPX, I noticed an undocumented feature: a let%lwt ... structure item becomes a call to Lwt_main.run. It might be impossible to support this on Node.js in a reasonable way. I'm not sure if we want to deprecate it yet, but it's good that it is not documented.
  • -no-sequence is the most legitimate of the PPX options. Users that want >> as a definable operator may be using it to suppress Lwt's >>. I'm not sure if the warning will be too noisy for them.
  • This PR doesn't check for [%lwt let ...], just [%lwt ...] when it would expand to Lwt.catch .... We should probably disable [%lwt let ...] and [%lwt ...] around all other constructs, by checking the location of the %lwt extension point, as is being done in Ppx: add support for begin%lwt e1; e2; end in ppx extension #525 for ;. This is still being discussed there, so left for future work.
  • @kandu, this PR doesn't include your change about inserting spaces into command line argument descriptions. Whichever order this PR and Ppx: add support for begin%lwt e1; e2; end in ppx extension #525 get merged in, I'll be sure to port/cherry-pick that commit and you will get credit for it :)

Some time after deprecating all this, maybe in lwt_ppx 2.0.0, we can delete support for all these features from the PPX, making it much simpler than it is now. A side effect of factoring the PPX out into lwt_ppx is that it can have its own release cycle, so we could do this without a major release of the main package lwt.

@aantron
Copy link
Collaborator Author

aantron commented Jan 2, 2018

Also, I believe most of this stuff was included in the PPX to make it more obvious how to convert from the Camlp4 syntax. However, these particular features turned out to be not needed by most users.

@copy
Copy link
Contributor

copy commented Jan 2, 2018

[%finally ...] should be replaced by [%lwt.finally ...]

May I ask what the rationale is behind this change? I don't mind updating my software, I just prefer having a less noisy version. A common pattern in ppxs to avoid name clashes is to provide both a prefixed and a non-prefixed version. For example, from ppx_deriving:

The [%derive.x:] syntax can be shortened to [%x:], given that the deriver x exists and the payload is a type. If these conditions are not satisfied, the extension node will be left uninterpreted to minimize potential conflicts with other rewriters.

@aantron
Copy link
Collaborator Author

aantron commented Jan 2, 2018

Just to avoid crowding the namespace. I got the impression that the main reason it exists in unprefixed form is that the Lwt Camlp4 syntax had a finally keyword.

I wasn't aware of this being a common PPX pattern, if that's so we can remove that commit. It's also the one I'm least convinced about deprecating.

@aantron
Copy link
Collaborator Author

aantron commented Jan 2, 2018

I checked the reverse dependences for lwt.finally as well. It's used in ocurl and otetris. Interestingly, it's also used in devkit, and it appears the commit that introduced lwt.finally is more recent than the one that introduced finally. Anyway, it's not clear that the community prefers either form, largely because the community doesn't seem to use this syntax.

Actually, in all cases except otetris, either syntax seems to have been the result of conversion from Camlp4. I was hoping to see if there is a preference either way for writing new code, but the sample is pretty small.

Of course, that only covers code in opam, so I don't really know.

@ygrek
Copy link
Contributor

ygrek commented Jan 2, 2018

Here is some quick data point :

$ ag --stats-only %lwt.finally
80 matches
41 files contained matches
35910 files searched
$ ag --stats-only %finally
83 matches
31 files contained matches
35910 files searched

@ygrek
Copy link
Contributor

ygrek commented Jan 2, 2018

PS I hope -no-sequence stays as long as >> is supported so that we can ensure no new >> is introduced in the code accidentally.

@Drup
Copy link
Member

Drup commented Jan 3, 2018

I think --no-debug should stay around, mostly because it's very useful when you are doing dev on the ppx itself.

I agree with @copy on %finally. Having both a qualified and unqualified version is a common idiom, and I think it's a useful one.

I mostly agree with the rest.

@aantron
Copy link
Collaborator Author

aantron commented Jan 3, 2018

@Drup, can you say how -no-debug helps with developing the PPX? I don't see what the benefit is.

I find the existence of -no-debug to be a hindrance to developing the PPX, as conditional code is needed because of it.

@aantron
Copy link
Collaborator Author

aantron commented Jan 3, 2018

Also I believe @kandu mentioned that it's easier to work on the PPX with -no-debug.

@aantron
Copy link
Collaborator Author

aantron commented Jan 5, 2018

Okay, I think I will merge this without the commit about deprecating [%finally].

@Drup: -no-debug will be deprecated, but it will remain for now. Hopefully, we will (have time to) figure out what's happening with stack traces soon, then we can decide what exactly to do with it. If we can't get backtraces to work using the PPX, we won't be emitting backtrace_ functions anyway, and the output will be simple too.

@ygrek: Indeed, we won't remove -no-sequence until >> is removed, and it will stick around for a while after that, too, as a no-effect option, to avoid breaking builds.

@Drup
Copy link
Member

Drup commented Jan 5, 2018

Well, -no-debug makes the code produced by -dsource/-dparsetree readable. :]

Is the conditional code such an issue ? It's fairly well localized and not extremely complicated.

@aantron
Copy link
Collaborator Author

aantron commented Jan 5, 2018

I don't think either the conditional code nor complex -dsource output is a big deal, no. I'd like to remove -no-debug from the docs and discourage anyone from passing it "in production" for now.

@aantron aantron merged commit c7ad8b3 into master Jan 7, 2018
@Drup
Copy link
Member

Drup commented Jan 7, 2018

I'd like to remove -no-debug from the docs and discourage anyone from passing it "in production" for now.

That's totally fair. :)

@aantron aantron deleted the ppx-deprecations branch January 10, 2018 15:47
aantron added a commit that referenced this pull request Mar 25, 2018
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.

None yet

4 participants