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

Add blogpost about uncurried mode #714

Merged
merged 3 commits into from
Sep 18, 2023

Conversation

fhammerschmidt
Copy link
Member

No description provided.

Copy link
Member

@cknitt cknitt left a comment

Choose a reason for hiding this comment

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

Excellent post! Thanks a lot! 👍

_blogposts/2023-09-15-uncurried-mode.mdx Outdated Show resolved Hide resolved
_blogposts/2023-09-15-uncurried-mode.mdx Outdated Show resolved Hide resolved
_blogposts/2023-09-15-uncurried-mode.mdx Outdated Show resolved Hide resolved
_blogposts/2023-09-15-uncurried-mode.mdx Outdated Show resolved Hide resolved
```rescript
(. param) => ()
```
* As ReScript could not fully statically analyze when to automatically uncurry a function over multiple files, it led to unnecessary `Curry.` calls in the emitted JavaScript code.
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we can clearly state here than function calls in uncurried mode are now guarantied to get compiled as simple JS function calls, which is quite nice for readability of the generated JS code but also for performance (even though it was not that significant) and sometimes even correctness when applied on bindings (Curry sometimes badly played with this and other JS features we don't care about in rescript).

Not sure it's worth being publicized but now you can even bind classes to simple rescript records which are sometimes much nicer to use than using an opaque type and a function:

myLogger->Logger.info("foo")
// vs 
myLogger.info("foo")

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. I am not sure about the class suggestion either. I only added your first point.

function calls in uncurried mode are now guarantied to get compiled as simple JS function calls

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you maybe give me a full example?

Copy link
Contributor

Choose a reason for hiding this comment

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

(f) => f()

is an example.
Or a more realistic example using that pattern.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I should have clarified I meant for classes as records.

Copy link
Contributor

@tsnobip tsnobip left a comment

Choose a reason for hiding this comment

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

I don't see anything more to add now. Great job @fhammerschmidt!

@fhammerschmidt fhammerschmidt marked this pull request as ready for review September 18, 2023 07:11
@cristianoc cristianoc merged commit 4eeb101 into rescript-lang:master Sep 18, 2023
1 check passed
@fhammerschmidt fhammerschmidt deleted the uncurried-post branch September 18, 2023 10:43
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