[gambit-list] Current namespace at the repl

Steve Graham jsgrahamus at yahoo.com
Thu Jul 28 20:01:47 EDT 2016


Thanks, Gerald.  Very interesting.

      From: Gerald Klix <gambit.00 at klix.ch>
 To: gambit-list at iro.umontreal.ca 
 Sent: Thursday, July 28, 2016 11:00 AM
 Subject: Re: [gambit-list] Current namespace at the repl
   
 Steve, maybe I can help. 
 ##decompile retrieve the source code of a procedure (if available): > (##decompile (##lambda () test))
 (lambda () test) If you change the name-space with:
  > (namespace ("test-namespace#"))
 
 decompile yields:
 
 > (##decompile (##lambda () test))
 (lambda () test-namespace#test)
 
 That means you have to strip the symbol suffix `test`
 to get the name-space.
 
 If you use the empty symbol, denoted by ||, you get the name-space
 symbol directly:
 
 > (##decompile (##lambda () ||))  
 (lambda () test-namespace#)
 
 With this information, one can define the following macro:
 
 > (define-macro (##current-namespace) (##symbol->string (eval (##quote (##caddr (##decompile (##lambda () ||)))))))           
 
 For e newly started gsi you get:
 
 >(##current-namespace)                                                                                          
 ""
 
 If you change the name-space you get:
 
 > (namespace ("test-namespace#"))
 >(##current-namespace)                                                                                          
 "test-namespace#"
 
 
 HTH,
 
 Gerald
 
 
 Am 28.07.2016 um 19:12 schrieb Steve Graham:
  
 Marc,
   Could you explain this a bit?

Thanks, Steve

      From: Marc Feeley <feeley at iro.umontreal.ca>
 To: Duncan Watts <djmwatts at gmail.com> 
Cc: Gambit-list at iro.umontreal.ca
 Sent: Thursday, July 28, 2016 4:22 AM
 Subject: Re: [gambit-list] Current namespace at the repl
   
A bit of a hack... Try:

(##caddr (##decompile (##lambda () ||)))

You can define a macro based on that idea.

Marc

 
 On Jul 28, 2016, at 12:09 PM, Duncan Watts <djmwatts at gmail.com> wrote:

Is there a function (or would it be easy to access the internals to write one) to find out what the currently active namespace is at the repl. Ie after entering a few (namespace ("foo#")) expressions it would be nice to be able check what the current namespace is with eg (current-namespace) --> "foo#"

Thanks
Duncan
_______________________________________________
Gambit-list mailing list
Gambit-list at iro.umontreal.ca
https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
 
 _______________________________________________
Gambit-list mailing list
Gambit-list at iro.umontreal.ca
https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list


  
 
  
 _______________________________________________
Gambit-list mailing list
Gambit-list at iro.umontreal.ca
https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
 
 
 
_______________________________________________
Gambit-list mailing list
Gambit-list at iro.umontreal.ca
https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list


  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20160729/415a9870/attachment.htm>


More information about the Gambit-list mailing list