-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Improve Texp_record constructor representation #516
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
Improve Texp_record constructor representation #516
Conversation
Merged recent trunk and fix propagation of record update type informations |
5914078
to
455a4b5
Compare
Re-rebased to the current trunk. Also use the type information to populate makeblock kinds in case of record update and add some test to check that this effectively allow unboxing in case of record update. This test was failing first due to a bug introduced by #538 . This contain the fix for it. |
Note also #538 changed the evaluation order of records. |
@garrigue @lpw25 or @alainfrisch would you object to this change ? |
I think it's a good change, but I did not review the patch itself.
Why not Moreover, the comment in Typedtree is confusing since it leads to believe that only overridden fields are listed. Perhaps just adding a sentence about the fact that all fields of the record type are listed in the arrays would help. |
I would also recommend switching to inline records where there are more than a pair of parameters, for clarity. |
@alainfrisch, no real reason, it made some change a bit smaller, but this is marginal. Thanks for the suggestions, I will try this. |
38948fe
to
60a8e1d
Compare
Rererebased... And applied @alainfrisch suggestions |
@bluddy in that case the name of the type of each field is probably sufficient to describe what is its concern, but that should probably go in another pr soon |
The order I suggested ( Regarding (inline or not) record for the arguments: if you think this is a good idea, why not doing it in this PR? Typedtree is processed by external tools (reading .cmt files) so we should indeed aim at user-friendliness and stability (i.e. not change again the definition post 4.04). |
It also allows to recover the type of kept fields in a { record with field = expr } expression
The expressions defining a record are evaluated from the last field in the type definition to the first one.
@@ -181,6 +181,26 @@ module Stdlib = struct | |||
| None -> default | |||
| Some a -> f a | |||
end | |||
|
|||
module Array = struct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This helper module is now useless, I think.
7c28f45
to
32cbe38
Compare
If the type is { l1: t1; l2: t2 }, the expression | ||
{ E0 with t2=P2 } is represented as | ||
Texp_record | ||
([| l1, Kept t1; l2 Override P2 |], representation, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be updated.
Good to merge in my opinion (after fixing the doc). |
@alainfrisch thanks for the review. |
…entation Improve Texp_record constructor representation
Remove caml_root API
* Generalize Table.Regular * Generalize Stats component * Generalize Testimonials * Generalize UserLevelIntroduction * Generalize MediaCarousel * Extract Timeline * Factor out Blog * Add components to storybook * Add Page elements to storybook. * Add a few more examples of Page.Basic * Add examples of PageTitles * Add Page Containers * Implement ContentGrid component. * Extract VerticalHighlightCard * Add examples of ContentGrid. * Add example of VerticalHighlightCard
Accessing record information in the typedtree is not very practical, and the information about the type of kept fields (when using the
{ record with label = exp }
construct) is available.I propose to replace it by:
This allows to easily access a particular field information (instead of searching for a field with the right field position).
The main motivation for this change is to provide the type information to translcore to propagate it to the lambda. In particular, the PR #336 would make use of it. I had a previous version that needed to do some unification after the type checking, but this version is a lot cleaner.
Notice that even if we lost the order of the fields in the parsetree, this does not affect the evaluation order. I added a test to verify that.
Notice that the evaluation order for record update depend on the number of fields updated:
Would anyone object if I changed the order to avoid this strangeness ?