Re: Generative and nongenerative record types
Marc Nieper-Wißkirchen 02 Nov 2022 14:57 UTC
In case someone is interested; below is a quick-and-dirty Emacs hack I
just wrote.
Am Mi., 2. Nov. 2022 um 14:09 Uhr schrieb Marc Nieper-Wißkirchen
<xxxxxx@nieper-wisskirchen.de>:
> But I see why you say that UID-less nongenerative records are also
> problematic. For quick-and-dirty programming and some backward
> compatibility, I like to leave them in the language (at least until I
> have told Emacs to generate UIDs for me), but at least we can
> encourage implementations to raise a continuable exception of type
> &warning whenever they expand a UID-less nongenerative record type.
(defun scheme-insert-record-type-definition (record-name)
"Insert a record-type defintion for RECORD-NAME."
(interactive "sRecord name: ")
(insert "(define-record-type ")
(insert record-name)
(newline)
(indent-according-to-mode)
(insert "(nongenerative ")
(insert record-name)
(insert "-")
(insert (substring (with-output-to-string
(call-process "uuidgen" nil standard-output))
0 -1))
(insert ")")
(newline)
(indent-according-to-mode)
(insert "(fields ")
(save-excursion
(insert "))")
(newline)
(indent-according-to-mode)))
(add-hook 'scheme-mode-hook
(lambda () (local-set-key (kbd "C-c r")
#'scheme-insert-record-type-definition)))