From: Andy Wingo <wingo@pobox.com>
To: guile-devel <guile-devel@gnu.org>
Subject: deprecating struct permissions?
Date: Sun, 21 Jul 2013 12:50:24 +0200 [thread overview]
Message-ID: <874nbokwzz.fsf@pobox.com> (raw)
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/
next reply other threads:[~2013-07-21 10:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-21 10:50 Andy Wingo [this message]
2013-08-17 12:20 ` deprecating struct permissions? Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874nbokwzz.fsf@pobox.com \
--to=wingo@pobox.com \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).