From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.bugs Subject: bug#11198: prefab structs in guile Date: Thu, 05 Jul 2012 23:06:56 +0200 Message-ID: <878vex534f.fsf__23295.983442995$1341522505$gmane$org@pobox.com> References: <877gui7i3y.fsf@pobox.com> <87ipe2dizn.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1341522505 18780 80.91.229.3 (5 Jul 2012 21:08:25 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 5 Jul 2012 21:08:25 +0000 (UTC) Cc: 11198@debbugs.gnu.org, guile-devel To: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Thu Jul 05 23:08:22 2012 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SmtHa-0001HF-2I for guile-bugs@m.gmane.org; Thu, 05 Jul 2012 23:08:14 +0200 Original-Received: from localhost ([::1]:34313 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmtHZ-0006ap-0L for guile-bugs@m.gmane.org; Thu, 05 Jul 2012 17:08:13 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:37665) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmtHV-0006aZ-IN for bug-guile@gnu.org; Thu, 05 Jul 2012 17:08:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SmtHT-0002BG-NS for bug-guile@gnu.org; Thu, 05 Jul 2012 17:08:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41496) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmtHT-0002B2-HN for bug-guile@gnu.org; Thu, 05 Jul 2012 17:08:07 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SmtMD-0003Xx-JQ for bug-guile@gnu.org; Thu, 05 Jul 2012 17:13:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andy Wingo Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Thu, 05 Jul 2012 21:13:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11198 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 11198-submit@debbugs.gnu.org id=B11198.134152272213569 (code B ref 11198); Thu, 05 Jul 2012 21:13:01 +0000 Original-Received: (at 11198) by debbugs.gnu.org; 5 Jul 2012 21:12:02 +0000 Original-Received: from localhost ([127.0.0.1]:51042 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SmtLG-0003Wo-5v for submit@debbugs.gnu.org; Thu, 05 Jul 2012 17:12:02 -0400 Original-Received: from a-pb-sasl-sd.pobox.com ([74.115.168.62]:34400 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SmtLE-0003WQ-0Q for 11198@debbugs.gnu.org; Thu, 05 Jul 2012 17:12:00 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by b-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 54A0AB677; Thu, 5 Jul 2012 17:07:05 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=idGUnGHwNRVJ Iw0Ld1UwxYQkcXg=; b=RfEeb9XOe2apLqfuV2kaM5XXWXNVs0LJMbvL1SzbbFYP Kb+2QABMt4SUdOl0rH2cgCO5PWjAbIENu3HbPmPgf34Fj30DGr9yDPNAS0ntKlz1 WqRKFi6OQwwhRRla8wnF7IbmMRsDf4ATRJhCjnRPeToUb6P3OcrXnux9uJV66/k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=sasl; b=TBtJrI aseJZpBGJZNJdsV4NcgtT9q4uu31A1f8eX6wJ0hN0bPgBEovmpaD7cigwV6KMWXI SUcxwmCCOFbZ8lr1Jfaj2g7MX8cmed5AOrl/y4bwZfuVn9fKS+4FkBlJxuBjHMAt dO8UMBY1716fyAUR/TSgebNMhR/aeFBBdrvWo= Original-Received: from b-pb-sasl-sd. (unknown [127.0.0.1]) by b-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 4BC35B676; Thu, 5 Jul 2012 17:07:05 -0400 (EDT) Original-Received: from badger (unknown [89.131.176.233]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by b-pb-sasl-sd.pobox.com (Postfix) with ESMTPSA id 85DE6B675; Thu, 5 Jul 2012 17:07:04 -0400 (EDT) In-Reply-To: <87ipe2dizn.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Thu, 05 Jul 2012 22:57:00 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) X-Pobox-Relay-ID: 5F54A134-C6E5-11E1-8CFC-FA6787E41631-02397024!b-pb-sasl-sd.pobox.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:6393 Archived-At: On Thu 05 Jul 2012 22:57, ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Andy Wingo skribis: > >> Then you would modify the reader to call out to (ice-9 prefab) with >> the list after #s, e.g. the (foo ...) in #s(foo ...). (ice-9 prefab) >> would return the record, creating the RTD if needed. > > The problem with this is that one could precisely forge instances of a > given record type, thereby breaking the type safety we currently have > (each instance of a record type is genuine, in the sense of Rees=E2=80=99= =E2=80=9CA > Security kernel Based on the Lambda-Calculus=E2=80=9D.) > > Does Racket address this somehow? See: http://docs.racket-lang.org/guide/define-struct.html?q=3Drecord&q=3Dstruc= ts&q=3Drecords#(part._prefab-struct) Specifically: Every prefab structure type is transparent=E2=80=94but even less abstract= than a transparent type, because instances can be created without any access to a particular structure-type declaration or existing examples. Overall, the different options for structure types offer a spectrum of possibilities from more abstract to more convenient: Opaque (the default) : Instances cannot be inspected or forged without access to the structure-type declaration. As discussed in the next section, constructor guards and properties can be attached to the structure type to further protect or to specialize the behavior of its instances. Transparent : Anyone can inspect or create an instance without access to the structure-type declaration, which means that the value printer can show the content of an instance. All instance creation passes through a constructor guard, however, so that the content of an instance can be controlled, and the behavior of instances can be specialized through properties. Since the structure type is generated by its definition, instances cannot be manufactured simply through the name of the structure type, and therefore cannot be generated automatically by the expression reader. Prefab : Anyone can inspect or create an instance at any time, without prior access to a structure-type declaration or an example instance. Consequently, the expression reader can manufacture instances directly. The instance cannot have a constructor guard or properties. Since the expression reader can generate prefab instances, they are useful when convenient serialization is more important than abstraction. Opaque and transparent structures also can be serialized, however, if they are defined with define-serializable-struct as described in Datatypes and Serialization. Andy --=20 http://wingolog.org/