Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006314OCamlOCaml generalpublic2014-02-02 13:492014-02-04 11:09
Reportertom.j.ridge 
Assigned Togarrigue 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusassignedResolutionopen 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0006314: Allow "functional record update" for objects
DescriptionWith records, one can functionally update a field e.g. as

{ r with some_field=new_value }

And new_value may, of course, be a function.

The request is for similar functionality for objects.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0010873)
jpdeplaix (reporter)
2014-02-02 22:25

I agree, this would be useful.
(0010874)
garrigue (manager)
2014-02-03 14:45

What you are asking for is not completely clear.

The simple one (and closest to functional update) would be to allow just to override methods externally.
I.e., you just build a new immediate object forwarding most calls to the original object, and redefining some methods (but not visible from the original ones). Actually this is just a kind of syntactic sugar, but requiring to know the type of the object.

Another meaning would be to copy the object, changing the method table.
Doable too, but rather different, as in this case the state is not shared.
Moreover this require that methods have exact types: this would be unsound if methods were allowed to have subtypes in subclasses (as per the Abadi-Cardelli book).

Finally you might want to update the method table of the current object. But in that case this is destructive update, not functional, and this would break completely the semantics.

Also, for soundness reasons, in none of this case you would be allowed to access value fields from newly defined methods (they do not appear in the object interface).
(0010875)
tom.j.ridge (reporter)
2014-02-03 14:54

Without knowing much about objects, I believe I am asking for

"The simple one (and closest to functional update) would be to allow just to override methods externally."

But, the scenario I am in means that I don't know exactly which methods are available on the object (but I know one method that is - the method I want to override). This means that I can't just make a new object (with methods delegating to the old object except for the "updated" method).

I *think* this makes semantic sense, but I'm not sure.
(0010876)
tom.j.ridge (reporter)
2014-02-03 15:00

Also, it would be super-useful if there was support for adding in new methods e.g.

{{ myobj with some_new_method=some_fun }}

if this makes sense.

- Issue History
Date Modified Username Field Change
2014-02-02 13:49 tom.j.ridge New Issue
2014-02-02 22:25 jpdeplaix Note Added: 0010873
2014-02-03 14:45 garrigue Note Added: 0010874
2014-02-03 14:45 garrigue Assigned To => garrigue
2014-02-03 14:45 garrigue Status new => feedback
2014-02-03 14:54 tom.j.ridge Note Added: 0010875
2014-02-03 14:54 tom.j.ridge Status feedback => assigned
2014-02-03 15:00 tom.j.ridge Note Added: 0010876


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker