1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Deprecate opaque struct fields

* NEWS: Add entry.
* doc/ref/api-data.texi (Vtables, Structure Basics): Remove mention of
  opaque field protection.
* libguile/struct.c (scm_make_struct_layout, scm_make_struct_no_tail):
  Remove discussion of opaque fields.
  (set_vtable_layout_flags): Issue a deprecation warning when opaque
  fields are used.
This commit is contained in:
Andy Wingo 2017-09-23 11:14:27 +02:00
parent 84aa050f92
commit b0ecf83ef0
3 changed files with 27 additions and 15 deletions

View file

@ -71,8 +71,8 @@ SCM_DEFINE (scm_make_struct_layout, "make-struct-layout", 1, 0, 0,
"type, the second a field protection. Allowed types are 'p' for\n"
"GC-protected Scheme data, 'u' for unprotected binary data. \n"
"Allowed protections\n"
"are 'w' for mutable fields, 'h' for hidden fields, 'r' for read-only\n"
"fields, and 'o' for opaque fields.\n\n"
"are 'w' for mutable fields, 'h' for hidden fields, and\n"
"'r' for read-only fields.\n\n"
"Hidden fields are writable, but they will not consume an initializer arg\n"
"passed to @code{make-struct}. They are useful to add slots to a struct\n"
"in a way that preserves backward-compatibility with existing calls to\n"
@ -174,6 +174,13 @@ set_vtable_layout_flags (SCM vtable)
flags &= ~SCM_VTABLE_FLAG_SIMPLE_RW;
break;
case 'o':
case 'O':
scm_c_issue_deprecation_warning
("Opaque struct fields are deprecated. Struct field protection "
"should be layered on at a higher level.");
/* Fall through. */
default:
flags = 0;
}
@ -564,8 +571,8 @@ SCM_DEFINE (scm_make_struct_no_tail, "make-struct/no-tail", 1, 0, 1,
"The @var{init1}, @dots{} are optional arguments describing how\n"
"successive fields of the structure should be initialized.\n"
"Only fields with protection 'r' or 'w' can be initialized.\n"
"Fields with protection 'o' can not be initialized by Scheme\n"
"programs.\n\n"
"Hidden fields (those with protection 'h') have to be manually\n"
"set.\n\n"
"If fewer optional arguments than initializable fields are supplied,\n"
"fields of type 'p' get default value #f while fields of type 'u' are\n"
"initialized to 0.")