From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: deprecating struct permissions? Date: Sun, 21 Jul 2013 12:50:24 +0200 Message-ID: <874nbokwzz.fsf@pobox.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1374403843 28828 80.91.229.3 (21 Jul 2013 10:50:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 21 Jul 2013 10:50:43 +0000 (UTC) To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Jul 21 12:50:46 2013 Return-path: Envelope-to: guile-devel@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 1V0rDy-0002Jo-Ai for guile-devel@m.gmane.org; Sun, 21 Jul 2013 12:50:46 +0200 Original-Received: from localhost ([::1]:52829 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0rDx-0002bW-QJ for guile-devel@m.gmane.org; Sun, 21 Jul 2013 06:50:45 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47265) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0rDk-0002bL-LX for guile-devel@gnu.org; Sun, 21 Jul 2013 06:50:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V0rDj-0001GT-GB for guile-devel@gnu.org; Sun, 21 Jul 2013 06:50:32 -0400 Original-Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:58135 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0rDj-0001GI-CH for guile-devel@gnu.org; Sun, 21 Jul 2013 06:50:31 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id AAB84DE4B for ; Sun, 21 Jul 2013 06:50:27 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to :subject:date:message-id:mime-version:content-type; s=sasl; bh=C bmnWa8eWVM3b5LESNufo0UIOs8=; b=IR8oUpYUfagQGgIaHBSort2amaokAZ7nd bSBbUFBN8qeI4+H01i0t85WB0xJB2qXUQJ2YyV7ONq6W/CEHm8OsyfxiK8W6/fRI IQHwB4EFiOMciTl/OhJO+88tl0UnxI0IBgqu3fTY+aKFB9EaI4YDMwpGd0SZGsXu ic1uI0DSS4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:subject :date:message-id:mime-version:content-type; q=dns; s=sasl; b=fot K2etAcZJsBi7LB/l4ODbLwdnBTJKw1I2yxyBTk8DxcSz+/RPe+4SOWS9UsMGru3T n+0eGxSbby+zCGqR+uKhH4AEay/ZZZPocBf0+KHCxGwng2mmQqBYUli4BLg215H/ kCCFB2aDKYagu5ht9iYzSGbX4MnVW9sxIy5vsNOs= Original-Received: from a-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id A39A7DE4A for ; Sun, 21 Jul 2013 06:50:27 -0400 (EDT) Original-Received: from badger (unknown [88.160.190.192]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id F108CDE49 for ; Sun, 21 Jul 2013 06:50:26 -0400 (EDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-Pobox-Relay-ID: 5A709D32-F1F3-11E2-8C08-9E6C0E5B5709-02397024!a-pb-sasl-quonix.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 208.72.237.25 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:16536 Archived-At: Hi, I would like to deprecate struct permissions. Struct permissions are an aspect of structs that lets the vtable specify which of a struct's fields are mutable. It's expressed in the layout symbol, which can be like "pwpwpw" for three mutable fields, or "prprpr" for three read-only fields. Struct permissions are bad in three ways. First of all, immutability is a concept best added at a higher level. For example, SRFI-9 records allow you to create immutable records, simply by not exposing setters. Structs are a low-level concept, and the mutability checks in structs actually duplicate concepts that are better expressed at a high level. Structs are capabilities to build abstractions, not abstractions in and of themselves. Second, "pr" slots aren't really immutable memory -- they are initialized when the struct is created. I would like to be able to compile simple make-struct invocations into separate allocate-struct and struct-set! operations, and "pr" slots are getting in the way -- I don't want to have to add a separate struct-set!-no-really-it's-ok-this-struct-set!-is-initialization instruction. Finally, struct permissions rely on the struct layout symbol mechanism, which is an abomination of an interface. Ideally I'd like to remove tail arrays, self fields, opaque fields, read-only fields, and the layout symbol in the future, instead replaced by a simple field count and bitfield of "raw" values (the "u" fields). So for 2.2 we could have all of these features map to "pw" fields, and in 2.4 we could remove them entirely. Or we could deprecate them in 2.0 already; dunno. Perhaps that is best. I'm not entirely happy with this proposal -- I would like to prevent people from mutating nfields in a vtable, for example. (Class redefinition is still possible of course.) But however we do things, we need a low-level abstraction that underpins records, and making a new lower-level interface below structs seems like a lose to me. Thoughts? Andy -- http://wingolog.org/