I suggest we ...

Allow record-like {obj with newvals...} syntax for arbitrary classes

The { oldObj with newval1=x ... } syntax is great syntax - I'd like to see it available for other objects, whether they are defined in F# or not.

I suggest:
- If the object has an IRecordClone (or whatever) implementation (or simply an implementation of a required method), then call it first. This would allow the copying of private data, etc. It returns the new object.
- If there was no pre-copy method to call, or after it runs, perform the standard record-like behavior of copying Public properties over to the new object.

2 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    mikero shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    2 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...
      • mikero commented  ·   ·  Flag as inappropriate

        The related feature is to allow records to take part in inheritance

      • mikero commented  ·   ·  Flag as inappropriate

        - *Copying all but the override values*
        - and finally setting the new values, obviously

      F# Language

      Feedback and Knowledge Base