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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 626247FB0A for ; Mon, 8 Dec 2014 10:34:50 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of goswin-v-b@web.de) identity=pra; client-ip=212.227.15.4; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="goswin-v-b@web.de"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of goswin-v-b@web.de designates 212.227.15.4 as permitted sender) identity=mailfrom; client-ip=212.227.15.4; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="goswin-v-b@web.de"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mout.web.de) identity=helo; client-ip=212.227.15.4; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="postmaster@mout.web.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: As0EAGpvhVTU4w8EnGdsb2JhbABag1hYthOQC4EjhHACgSUWAQEBAQERAQEBAQEGDQkJFC6EAgEBAQMBJxM0BgoLCxgJBCEPBQ0bCSsSiBMBAwkJBAnOAx8rAwqFdQEBCAEBAQEejiKBVV+DIYEVBYRSBo5sdoM8gWiBV4UKDIZCigFugQOBQAEBAQ X-IPAS-Result: As0EAGpvhVTU4w8EnGdsb2JhbABag1hYthOQC4EjhHACgSUWAQEBAQERAQEBAQEGDQkJFC6EAgEBAQMBJxM0BgoLCxgJBCEPBQ0bCSsSiBMBAwkJBAnOAx8rAwqFdQEBCAEBAQEejiKBVV+DIYEVBYRSBo5sdoM8gWiBV4UKDIZCigFugQOBQAEBAQ X-IronPort-AV: E=Sophos;i="5.07,537,1413237600"; d="scan'208";a="92342037" Received: from mout.web.de ([212.227.15.4]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 08 Dec 2014 10:34:49 +0100 Received: from frosties.localnet ([134.3.241.185]) by smtp.web.de (mrweb003) with ESMTPSA (Nemesis) id 0LnS3i-1XUtss2N1K-00hdUu for ; Mon, 08 Dec 2014 10:34:48 +0100 Received: from mrvn by frosties.localnet with local (Exim 4.82) (envelope-from ) id 1XxuiN-0006nf-Qv for caml-list@inria.fr; Mon, 08 Dec 2014 10:34:47 +0100 Date: Mon, 8 Dec 2014 10:34:47 +0100 From: Goswin von Brederlow To: caml-list@inria.fr Message-ID: <20141208093447.GA25411@frosties> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Provags-ID: V03:K0:QI9dVpcw0NsbSCJewC9NiFePHpIYEsF2wSh1p5UWZ6Je2G4W5ld eNAiboDkU7+to9Jwjsh/Mifd7Sfw9XUFR3+iXRorYO0ztErLZo5p0UGheu5/gf1vKJdfNid fBQ9Hvuok7R61KgzH8S75dOY3X4yKHWxxz8DCOBlRUmuT+zxx/XGlmx52Snq2q7Ro0rtp8W 3e2GDyoiT/QW87O5wIddA== X-UI-Out-Filterresults: notjunk:1; Subject: Re: [Caml-list] Object Features On Sun, Nov 30, 2014 at 02:45:19PM +0100, Philippe Wang wrote: > Hi, > > Just some quick thoughts about 3.: it's not object matching! It looks > a little like it, but it's not at all, in the sense that it's not at > all like the rest of OCaml's pattern matching stuff. > I would somewhat find it useful, but probably too misleading and > confusing to encourage having this feature. > > I was going to say it's not shorter or easier to write it this way, but actually > let myFunction delta {} = x + y + delta > is a little shorter than something like > let myFunction delta (o: ) = o#x + o#y + delta > but, still, I don't really see something good in there. > > Cheers, > Philippe Wang How about this syntax (similar to local open of modules): let myFunction delta o = o#(x + y + delta) MfG Goswin > On Sun, Nov 30, 2014 at 5:24 AM, Jordan W wrote: > > 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 > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs