guile-user
[Top][All Lists]
Advanced

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

Re: can't export conditional variable set with 'cond'


From: Skyler Ferris
Subject: Re: can't export conditional variable set with 'cond'
Date: Fri, 02 Feb 2024 00:00:56 +0000

It's also worth mentioning that a "lispier" way of doing this is to use 
parameters, described in "6.11.2 Parameters". I get the impression that 
you were asking this more for curiosity about how the language 
implementation works than to solve a problem, but I might be wrong in 
that assumption and people who are looking to solve this problem might 
come upon this thread in the future. The example looks like this after 
re-writing to use parameters (and it displays the correct output on my 
machine):

-------------testexport.scm begin----------------------------------
(define-module (testexport)
   #:use-module (ice-9 pretty-print)
   #:use-module (env)
   )

(define (main)
   (pretty-print (string-append  "varA in main: " (varA)))
   (pretty-print (string-append  "varB in main: " (varB)))
   (pretty-print (string-append  "varC in main: " (varC)))
   )

(main)
-------------testexport.scm end----------------------------------

-------------env.scm begin----------------------------------
(define-module (env)
   #:use-module (ice-9 pretty-print)
   #:export(varA varB varC))

(define varA (make-parameter "A"))
(define varB (make-parameter ""))
(define varC (make-parameter ""))
(define testval "x")

(cond
  ((string= testval "x") (varB "B"))
  ((string= testval "y") (varB "error"))
  ((string= testval "z") (varB "null"))
  )
(pretty-print (string-append "varB post cond: " (varB)))

(when (string= testval "x")  (varC "C"))
(pretty-print (string-append "varC post if: " (varC)))
-------------env.scm end----------------------------------





reply via email to

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