unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* convert environment to module `name'
@ 2017-03-04 18:57 Matt Wette
  2017-03-05  8:17 ` Thien-Thi Nguyen
  0 siblings, 1 reply; 4+ messages in thread
From: Matt Wette @ 2017-03-04 18:57 UTC (permalink / raw)
  To: guile-user

I am working on “Compiling to the Virtual Machine”.  Guile passes an `env’ object to the parser/compiler which is apparently the module object for the desired execution environment.

To reference top-level variables in (external) tree-il I am using

	'(toplevel foo)

but I guess I should be using

	'(@ (mod from env) foo)

I don’t know how to get the list-symbol path “mod from env” from the env argument. Any ideas?

The following generates an error:

	`(@ ,env foo)

where env in write format looks like 

	<directory (guile-user) 10c8fbbd0>

Matt




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: convert environment to module `name'
  2017-03-04 18:57 convert environment to module `name' Matt Wette
@ 2017-03-05  8:17 ` Thien-Thi Nguyen
  2017-03-05 14:09   ` Matt Wette
  0 siblings, 1 reply; 4+ messages in thread
From: Thien-Thi Nguyen @ 2017-03-05  8:17 UTC (permalink / raw)
  To: guile-user

[-- Attachment #1: Type: text/plain, Size: 730 bytes --]


() Matt Wette <matt.wette@gmail.com>
() Sat, 4 Mar 2017 10:57:19 -0800

   I don’t know how to get the list-symbol path “mod from env”
   from the env argument.  Any ideas?

I think ‘module-name’ is what you need:

 scheme@(guile-user)> (current-module)
 $1 = #<directory (guile-user) 83e2630>
 scheme@(guile-user)> (module-name (current-module))
 $2 = (guile-user)

This is from a Guile 2.0.11 session.

-- 
Thien-Thi Nguyen -----------------------------------------------
 (defun responsep (query)
   (pcase (context query)
     (`(technical ,ml) (correctp ml))
     ...))                              748E A0E8 1CB8 A748 9BFA
--------------------------------------- 6CE4 6703 2224 4C80 7502


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: convert environment to module `name'
  2017-03-05  8:17 ` Thien-Thi Nguyen
@ 2017-03-05 14:09   ` Matt Wette
  2017-03-05 14:30     ` Matt Wette
  0 siblings, 1 reply; 4+ messages in thread
From: Matt Wette @ 2017-03-05 14:09 UTC (permalink / raw)
  To: guile-user


> On Mar 5, 2017, at 12:17 AM, Thien-Thi Nguyen <ttn@gnu.org> wrote:
> 
> 
> () Matt Wette <matt.wette@gmail.com>
> () Sat, 4 Mar 2017 10:57:19 -0800
> 
>   I don’t know how to get the list-symbol path “mod from env”
>   from the env argument.  Any ideas?
> 
> I think ‘module-name’ is what you need:
> 
> scheme@(guile-user)> (current-module)
> $1 = #<directory (guile-user) 83e2630>
> scheme@(guile-user)> (module-name (current-module))
> $2 = (guile-user)

Thanks!


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: convert environment to module `name'
  2017-03-05 14:09   ` Matt Wette
@ 2017-03-05 14:30     ` Matt Wette
  0 siblings, 0 replies; 4+ messages in thread
From: Matt Wette @ 2017-03-05 14:30 UTC (permalink / raw)
  To: guile-user


> On Mar 5, 2017, at 6:09 AM, Matt Wette <matt.wette@gmail.com> wrote:
> 
>> 
>> On Mar 5, 2017, at 12:17 AM, Thien-Thi Nguyen <ttn@gnu.org> wrote:
>> 
>> 
>> () Matt Wette <matt.wette@gmail.com>
>> () Sat, 4 Mar 2017 10:57:19 -0800
>> 
>>  I don’t know how to get the list-symbol path “mod from env”
>>  from the env argument.  Any ideas?
>> 
>> I think ‘module-name’ is what you need:
>> 
>> scheme@(guile-user)> (current-module)
>> $1 = #<directory (guile-user) 83e2630>
>> scheme@(guile-user)> (module-name (current-module))
>> $2 = (guile-user)
> 
> Thanks!

It works, but have to use @@.

scheme@(guile-user)> (define a 123)
scheme@(guile-user)> ,L javascript
Happy hacking with javascript!  To switch back, type `,L scheme'.
javascript@(guile-user)> a = 1
(set! (@@ (guile-user) a) (const 1))
javascript@(guile-user)> ,L scheme
Happy hacking with Scheme!  To switch back, type `,L javascript'.
scheme@(guile-user)> a
$1 = 1



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-03-05 14:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-04 18:57 convert environment to module `name' Matt Wette
2017-03-05  8:17 ` Thien-Thi Nguyen
2017-03-05 14:09   ` Matt Wette
2017-03-05 14:30     ` Matt Wette

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).