[racket] splicing internal define?

From: Marijn (hkBst at gentoo.org)
Date: Wed Sep 28 10:36:22 EDT 2011

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi list,

recent talk about internal define being considered the preferred style
made me focus on trying to use it more in my own code and resulted in
some thoughts which I'd like to throw out there without much sanity
checking on my part.

Consider:

#lang racket

(require racket/mpair)

(let ((value-store (mlist (mcons 'variable #f))))
  (define (variable-ref variable)
    (massoc variable value-store))
  (define (variable-set! variable value)
    (set-mcdr! (variable-ref variable) value)))

(variable-ref 'variable)


Currently racket complains about ``no expression after a sequence of
internal definitions'' for that first case, but what if that meant the
same as:


#lang racket

(require racket/mpair)

(define-values (variable-ref variable-set!)
  (let ((value-store (mlist (mcons 'variable #f))))
    (values
     (lambda (variable)
       (massoc variable value-store))
     (lambda (variable value)
       (set-mcdr! (variable-ref variable) value)))))

(variable-ref 'variable)


Marijn
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6DMOYACgkQp/VmCx0OL2wcXACgsrWPilIt4zNTs6gDjQDf0/n1
/5cAoKOOao0wvwzHuWBzR0jhK2FbwhqB
=swUJ
-----END PGP SIGNATURE-----


Posted on the users mailing list.