[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#34948] [PATCH 1/3] records: Allow thunked fields to refer to 'this-
From: |
Ludovic Courtès |
Subject: |
[bug#34948] [PATCH 1/3] records: Allow thunked fields to refer to 'this-record'. |
Date: |
Sat, 30 Mar 2019 11:37:48 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
Hello!
I’ve extended this a bit with these commits:
d8bead6c5d system: Define 'this-operating-system'.
adb6462c4c packages: Define 'this-package' and 'this-origin'.
d2be7e3c4b records: Support custom 'this' identifiers.
Now you can refer to ‘this-package’ and it will refer to the closest
package in scope. The good thing is that you can refer to
‘this-package’ from within, say, an <origin> field, and it will DTRT.
That also means you could have things such as:
(define-record-type* <origin>
;; …
(file-name origin-file-name (thunked)
(default (string-append (package-name this-package)
"-source"))))
… which is pretty fun when you think about it, since it allows you to
implicitly refer to the lexically surrounding package.
That reminds me of Scala’s “implicit parameters”:
https://docs.scala-lang.org/tour/implicit-parameters.html
Ludo’.