mit-scheme-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: get-environment-variables fails with error in MIT Scheme 11.2


From: Taylor R Campbell
Subject: Re: get-environment-variables fails with error in MIT Scheme 11.2
Date: Sun, 5 Jun 2022 16:29:33 +0000

> Date: Mon, 2 May 2022 19:30:40 +0000
> From: Sam Lee <samlee746@yahoo.com>
> 
> On 2022-05-01 12:30 +0000, Taylor R Campbell wrote:
> > Bug -- I backported a change to the release-11 branch but it depended
> > on another change I neglected to backport, sorry.  Should be fixed
> > now, and there's an automatic test which will catch this now.
> 
> Is there a workaround for MIT Scheme 11.2?

You can put this in your .scheme.init file until the next version:

((lambda (form) (eval form (->environment '(runtime os-primitive))))
'(define (get-environment-variables)
  (with-thread-mutex-lock %env-lock
    (lambda ()
      (let ((local-copy (hash-table-copy %local-env)))
        (hash-table-for-each (lambda (name value)
                               (if (not (hash-table-exists? local-copy name))
                                   (hash-table-set! local-copy name value)))
                             (env-cache))
        (let ((entries
               (hash-table-fold local-copy
                                (lambda (name value result)
                                  (if value
                                      (cons (cons name value) result)
                                      result))
                                '())))
          (sort entries (lambda (a b) (string<? (car a) (car b))))))))))

(The bug was on the last line, which I wrote as (sort entries string<?
car), a form that works now in the master branch but not in 11.2
because I hadn't backported the change to make sort accept a key
argument.)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]