From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id A5A8E7FB0A for ; Sun, 30 Nov 2014 05:24:33 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of jordojw@gmail.com) identity=pra; client-ip=209.85.217.181; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jordojw@gmail.com"; x-sender="jordojw@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of jordojw@gmail.com designates 209.85.217.181 as permitted sender) identity=mailfrom; client-ip=209.85.217.181; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jordojw@gmail.com"; x-sender="jordojw@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-lb0-f181.google.com) identity=helo; client-ip=209.85.217.181; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jordojw@gmail.com"; x-sender="postmaster@mail-lb0-f181.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvMBADubelTRVdm1lGdsb2JhbABbhC8EgwHLTgcWAQEBAQERAQEBAQcLCwkSMIQbEQQZARsYBgMSAwYHNwIkAREBBQFXiAgBAxKgA40ogyU9MYszgWyDCol0ChknDVqFTgEFDpAVg1SBUwWLFYUNhjeFbpNHGCiFWB4wgQSBQwEBAQ X-IPAS-Result: AvMBADubelTRVdm1lGdsb2JhbABbhC8EgwHLTgcWAQEBAQERAQEBAQcLCwkSMIQbEQQZARsYBgMSAwYHNwIkAREBBQFXiAgBAxKgA40ogyU9MYszgWyDCol0ChknDVqFTgEFDpAVg1SBUwWLFYUNhjeFbpNHGCiFWB4wgQSBQwEBAQ X-IronPort-AV: E=Sophos;i="5.07,486,1413237600"; d="scan'208";a="110267882" Received: from mail-lb0-f181.google.com ([209.85.217.181]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 30 Nov 2014 05:24:33 +0100 Received: by mail-lb0-f181.google.com with SMTP id 10so6935202lbg.40 for ; Sat, 29 Nov 2014 20:24:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=u/B8LAhlBb1LiGAVin+UtrjoenvFlWl6OOFenqlDJgA=; b=pK8ZNc0r0Bm6W0lIOXUwfKFyifs0hFam8jSlil1v0ZoaqH8x9aPgmdI3qzoolWkzV0 5rd9U7KVgcJFm7pO+Gcn6Qh5gpxMOQgy5tcKsEo5m5KO9q/xLs3EcHFpDRcUPzb4d4x0 Zv+BPzhG7uyijfykheHuX6MivT7OoJR7EynhODbriikP7Q2ha3wQvT5WghqS6FW+2OTk 96fw08jDrjIsA5COIt4rfdV8RnvEAadJMUk6LZ95qbTkSOljaNYA2PGAysrob7YQo8jV QTBXCwI8J/cdJBCXm4NIkKMi45AFTR+akXsDsfc6Qrq7TXp06864ATmDovZzpf2e/Paw JWLA== MIME-Version: 1.0 X-Received: by 10.152.1.193 with SMTP id 1mr5773397lao.45.1417321472135; Sat, 29 Nov 2014 20:24:32 -0800 (PST) Received: by 10.25.143.202 with HTTP; Sat, 29 Nov 2014 20:24:32 -0800 (PST) Date: Sat, 29 Nov 2014 20:24:32 -0800 Message-ID: From: Jordan W To: caml-list@inria.fr Content-Type: multipart/alternative; boundary=089e013c62ace1189d05090bdedf X-Validation-by: jordojw@gmail.com Subject: [Caml-list] Object Features --089e013c62ace1189d05090bdedf Content-Type: text/plain; charset=UTF-8 Hello, I've encountered several situations where I would have benefited from the following features. I am curious what some of the OCaml core developers think about them. 1. Object punning: I understand that object punning on "functional updates" to objects was recently added to trunk. This is a nice consistency, but I haven't found a way to perform object punning on methods or values for object *expressions*. let x = 10 let y = 20 let o = object method x method y end Which would create an object with two methods x, y that return x and y respectively. It may be easy to apply the same convention to object values. 2. Object extension: I believe that OCaml immediate objects are fairly under-appreciated, and most people could find useful applications for them (at least) in the form of row polymorphic records. However, there are several features that would make them even more powerful. The feature I long for the most is object extension (on immediate objects). OCaml has support for extending objects (inheritance), but only via classes. I understand that implementing this may complicate dynamic dispatch and/or use of `self`, but perhaps some compromise could be reached - something like a limited form of `inherit`, that is allowed to have different semantics and works on immediate objects (at least in the case when objects are being used as row-polymorphic records). let oldObj = object method x = 20 method greet = "hi" end let newObj = {} This is similar to Andreas Rossberg's Record Extensions in SuccessorML. New languages are picking up these extensible record features as described in Daan Leijen's paper [Extensible Records With Scoped Labels] and I suspect this feature will be of interest to many others. 3. Object matching. let myFunction delta {} = x + y + delta let myFunction delta o = match o with {} -> x + y + delta This may be relatively easy to implement (my reasoning is that I believe it could even be solved at the parsing stage (not that it would be a good idea to do so)). Thanks for listening. I'm curious if anyone's given thought to implementing these, and eager to hear thoughts/suggestions. Jordan --089e013c62ace1189d05090bdedf Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hello,

I've encountered several sit= uations where I would have benefited from the following features. I am curi= ous what some of the OCaml core developers think about them.

=
1. Object punning:
I understand that object punning on= "functional updates" to objects was recently added to trunk. Thi= s is a nice consistency, but I haven't found a way to perform object pu= nning on methods or values for object *expressions*.

=C2=A0 =C2=A0 let x =3D 10
=C2=A0 =C2=A0 let y =3D 20
=C2=A0 =C2=A0 let o =3D object
=C2=A0 =C2=A0 =C2=A0 method x=C2=A0 =C2=A0 =C2=A0 method y
=C2=A0 =C2=A0 end

Which would create an object with two methods x, y that return x a= nd y respectively. It may be easy to apply the same convention to object va= lues.

2. Object extension: I believe that OCaml im= mediate objects are fairly under-appreciated, and most people could find us= eful applications for them (at least) in the form of row polymorphic record= s. However, there are several features that would make them even more power= ful. The feature I long for the most is object extension (on immediate obje= cts). OCaml has support for extending objects (inheritance), but only via c= lasses. I understand that implementing this may complicate dynamic dispatch= and/or use of `self`, but perhaps some compromise could be reached - somet= hing like a limited form of `inherit`, that is allowed to have different se= mantics and works on immediate objects (at least in the case when objects a= re being used as row-polymorphic records).

=C2=A0 = =C2=A0 let oldObj =3D object method x =3D 20 method greet =3D "hi"= ; end
=C2=A0 =C2=A0 let newObj =3D {<oldObj with method x =3D = 10 >}

This is similar to Andreas Rossberg's= Record Extensions in SuccessorML.

New languages a= re picking up these extensible record features as described in Daan Leijen&= #39;s paper [Extensible Records With Scoped Labels] and I suspect this feat= ure will be of interest to many others.

3. Object = matching.

=C2=A0 =C2=A0 let myFunction delta {<= x; y; ..>} =3D x + y + delta

=C2=A0 =C2=A0 let = myFunction delta o =3D match o with
=C2=A0 =C2=A0 =C2=A0 =C2=A0 {= <x; y; .. >} -> x + y + delta


This may be relati= vely easy to implement (my reasoning is that I believe it could even be sol= ved at the parsing stage (not that it would be a good idea to do so)).


Thanks for listening. I'm curious i= f anyone's given thought to implementing these, and eager to hear thoug= hts/suggestions.

Jordan
--089e013c62ace1189d05090bdedf--