4 ms·
Here is a complete (and simpler) example, taken from my ~/.config/shepherd/init.scm: (define xscreensaver (make <service> #:provides
by ymse 9y ago
Here is a complete (and simpler) example, taken from my ~/.config/shepherd/init.scm:
(define xscreensaver (make <service>
#:provides '(xscreensaver)
#:start (make-forkexec-constructor
(list "/run/setuid-programs/xscreensaver" "-nosplash"))
#:stop (make-kill-destructor)))
(register-services xscreensaver)
- coldtea 9y agoAny reason for the fugly #: syntax? That's mandated by Guile?
- Avshalom 9y agoThey're keyword arguments, I suspect the #: prefix was chose precisely because it is ugly so it'll almost never conflict with a name a programmer might actually want to give as an argument, Racket uses it too. http://docs.racket-lang.org/guide/keywords.html http://docs.racket-lang.org/guide/keywords.html
- rekado 9y agoThe # is extensible reader syntax. You can install your own readers for characters following the #. #\ is for the character reader, #: for keywords, etc. Guix uses #~ for G-expressions, for example.
- reirob 9y agoThanks for providing the link to the documentation in Racket. For people like me who don't know how to program in Scheme, this quote from the documentation might make it click (it is at the end of the page): Despite their similarities, keywords are used in a different way than identifiers or symbols. Keywords are intended for use (unquoted) as special markers in argument lists and in certain syntactic forms. For run-time flags and enumerations, use symbols instead of keywords. The example below illustrates the distinct roles of keywords and symbols. Examples: > (define dir (find-system-path 'temp-dir)) ; not '#:temp-dir > (with-output-to-file (build-path dir "stuff.txt") (lambda () (printf "example\n")) ; optional #:mode argument can be 'text or 'binary #:mode 'text ; optional #:exists argument can be 'replace, 'truncate, ... #:exists 'replace)