* "unbound variable"
@ 2011-06-26 8:00 Tomas By
2011-06-27 3:40 ` nalaginrut
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Tomas By @ 2011-06-26 8:00 UTC (permalink / raw)
To: guile-user
Hi all,
I have an extended Guile interpreter with a C function "get-map",
defined by "scm_c_define_gsubr", that I then try to use in the
(pure Scheme) module "mapdisplay", with the following result:
| mapdisplay.scm:36:12: In expression (get-map wg name):
| mapdisplay.scm:36:12: Unbound variable: get-map
| ABORT: (unbound-variable)
| guile> get-map
| #<primitive-procedure get-map>
| guile>
Any ideas what is happening here? How can I debug it?
/Tomas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: "unbound variable"
2011-06-26 8:00 "unbound variable" Tomas By
@ 2011-06-27 3:40 ` nalaginrut
2011-06-27 8:12 ` Tomas By
2011-06-27 9:41 ` Peter Brett
2012-01-08 17:04 ` Andy Wingo
2 siblings, 1 reply; 10+ messages in thread
From: nalaginrut @ 2011-06-27 3:40 UTC (permalink / raw)
To: Tomas By; +Cc: guile-user
> Hi all,
>
> I have an extended Guile interpreter with a C function "get-map",
> defined by "scm_c_define_gsubr", that I then try to use in the
> (pure Scheme) module "mapdisplay", with the following result:
>
> | mapdisplay.scm:36:12: In expression (get-map wg name):
> | mapdisplay.scm:36:12: Unbound variable: get-map
> | ABORT: (unbound-variable)
> | guile> get-map
> | #<primitive-procedure get-map>
> | guile>
>
> Any ideas what is happening here? How can I debug it?
>
> /Tomas
>
>
>
I think you need to import this symbol in your module, in this case, I
think it's mapdisplay.scm. If get-map's not within a module, you'd need
to get this symbol with "dynamic-link" and it's friends.
--
GNU Powered it
GPL Protected it
GOD Blessed it
HFG - NalaGinrut
--hacker key--
v4sw7CUSMhw6ln6pr8OSFck4ma9u8MLSOFw3WDXGm7g/l8Li6e7t4TNGSb8AGORTDLMen6g6RASZOGCHPa28s1MIr4p-x hackerkey.com
---end key---
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: "unbound variable"
2011-06-27 3:40 ` nalaginrut
@ 2011-06-27 8:12 ` Tomas By
2011-06-27 8:38 ` nalaginrut
0 siblings, 1 reply; 10+ messages in thread
From: Tomas By @ 2011-06-27 8:12 UTC (permalink / raw)
To: guile-user
On Mon, June 27, 2011 05:40, nalaginrut wrote:
> I think you need to import this symbol in your module, in this case, I
> think it's mapdisplay.scm. If get-map's not within a module, you'd need
> to get this symbol with "dynamic-link" and it's friends.
It's in the top-level module.
| guile> (apropos "get-map")
| (guile-user): get-map #<primitive-procedure get-map>
My extensions are statically linked into a Scheme shell executable.
Do I need to extra-import top-level functions into my Scheme module?
How do I do that?
/Tomas
>> Hi all,
>>
>> I have an extended Guile interpreter with a C function "get-map",
>> defined by "scm_c_define_gsubr", that I then try to use in the
>> (pure Scheme) module "mapdisplay", with the following result:
>>
>> | mapdisplay.scm:36:12: In expression (get-map wg name):
>> | mapdisplay.scm:36:12: Unbound variable: get-map
>> | ABORT: (unbound-variable)
>> | guile> get-map
>> | #<primitive-procedure get-map>
>> | guile>
>>
>> Any ideas what is happening here? How can I debug it?
>>
>> /Tomas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: "unbound variable"
2011-06-27 8:12 ` Tomas By
@ 2011-06-27 8:38 ` nalaginrut
2011-06-27 8:56 ` Tomas By
0 siblings, 1 reply; 10+ messages in thread
From: nalaginrut @ 2011-06-27 8:38 UTC (permalink / raw)
To: Tomas By; +Cc: guile-user
> On Mon, June 27, 2011 05:40, nalaginrut wrote:
> > I think you need to import this symbol in your module, in this case, I
> > think it's mapdisplay.scm. If get-map's not within a module, you'd need
> > to get this symbol with "dynamic-link" and it's friends.
>
> It's in the top-level module.
>
> | guile> (apropos "get-map")
> | (guile-user): get-map #<primitive-procedure get-map>
>
> My extensions are statically linked into a Scheme shell executable.
>
> Do I need to extra-import top-level functions into my Scheme module?
> How do I do that?
>
> /Tomas
I can't give accurate answer because you provided less information. So I
just give a guess:
If you have wrapped a module in mapdisplay.scm, you'd have imported some
symbols out of this module. I know you can see get-map in REPL's
"current-module", but mapdisplay can't see it in it's own
"current-module". They are different.
If you write this get-map within a module, you may use "#:use-module" in
mapdisplay.scm. If not, you need to import it from your .so file with
FFI such as "dynamic-link". You may checkout it out in the manual.
--
GNU Powered it
GPL Protected it
GOD Blessed it
HFG - NalaGinrut
--hacker key--
v4sw7CUSMhw6ln6pr8OSFck4ma9u8MLSOFw3WDXGm7g/l8Li6e7t4TNGSb8AGORTDLMen6g6RASZOGCHPa28s1MIr4p-x hackerkey.com
---end key---
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: "unbound variable"
2011-06-27 8:38 ` nalaginrut
@ 2011-06-27 8:56 ` Tomas By
2011-06-27 9:18 ` nalaginrut
0 siblings, 1 reply; 10+ messages in thread
From: Tomas By @ 2011-06-27 8:56 UTC (permalink / raw)
To: NalaGinrut; +Cc: guile-user
Hi again,
Thanks for the help so far.
On Mon, June 27, 2011 10:38, nalaginrut wrote:
> I can't give accurate answer because you provided less information. So I
> just give a guess:
> If you have wrapped a module in mapdisplay.scm, you'd have imported some
> symbols out of this module. I know you can see get-map in REPL's
> "current-module", but mapdisplay can't see it in it's own
> "current-module". They are different.
> If you write this get-map within a module, you may use "#:use-module" in
> mapdisplay.scm. If not, you need to import it from your .so file with
> FFI such as "dynamic-link". You may checkout it out in the manual.
Well, as I tried to explain, "get-map" is statically linked into the
executable, defined with "scm_c_define_gsubr" which is called from the
"inner_main" that is passed to "scm_boot_guile".
I don't think I should have to also dynamically link it.
Do I need to do another "define_gsubr" (or whatever) from inside mapdisplay?
/Tomas
>> On Mon, June 27, 2011 05:40, nalaginrut wrote:
>> > I think you need to import this symbol in your module, in this case, I
>> > think it's mapdisplay.scm. If get-map's not within a module, you'd
>> need
>> > to get this symbol with "dynamic-link" and it's friends.
>>
>> It's in the top-level module.
>>
>> | guile> (apropos "get-map")
>> | (guile-user): get-map #<primitive-procedure get-map>
>>
>> My extensions are statically linked into a Scheme shell executable.
>>
>> Do I need to extra-import top-level functions into my Scheme module?
>> How do I do that?
>>
>> /Tomas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: "unbound variable"
2011-06-27 8:56 ` Tomas By
@ 2011-06-27 9:18 ` nalaginrut
0 siblings, 0 replies; 10+ messages in thread
From: nalaginrut @ 2011-06-27 9:18 UTC (permalink / raw)
To: Tomas By; +Cc: guile-user
> Hi again,
>
> Thanks for the help so far.
>
> On Mon, June 27, 2011 10:38, nalaginrut wrote:
> > I can't give accurate answer because you provided less information. So I
> > just give a guess:
> > If you have wrapped a module in mapdisplay.scm, you'd have imported some
> > symbols out of this module. I know you can see get-map in REPL's
> > "current-module", but mapdisplay can't see it in it's own
> > "current-module". They are different.
> > If you write this get-map within a module, you may use "#:use-module" in
> > mapdisplay.scm. If not, you need to import it from your .so file with
> > FFI such as "dynamic-link". You may checkout it out in the manual.
>
> Well, as I tried to explain, "get-map" is statically linked into the
> executable, defined with "scm_c_define_gsubr" which is called from the
> "inner_main" that is passed to "scm_boot_guile".
>
> I don't think I should have to also dynamically link it.
>
> Do I need to do another "define_gsubr" (or whatever) from inside mapdisplay?
>
> /Tomas
>
Well, I see your situation. And I must say that I don't blend the
extension with executive entry file. So I'm not sure whether a symbol
imported in inner_main directly would be available in every module.
--
GNU Powered it
GPL Protected it
GOD Blessed it
HFG - NalaGinrut
--hacker key--
v4sw7CUSMhw6ln6pr8OSFck4ma9u8MLSOFw3WDXGm7g/l8Li6e7t4TNGSb8AGORTDLMen6g6RASZOGCHPa28s1MIr4p-x hackerkey.com
---end key---
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: "unbound variable"
2011-06-26 8:00 "unbound variable" Tomas By
2011-06-27 3:40 ` nalaginrut
@ 2011-06-27 9:41 ` Peter Brett
2011-06-27 21:44 ` Linas Vepstas
2012-01-08 17:04 ` Andy Wingo
2 siblings, 1 reply; 10+ messages in thread
From: Peter Brett @ 2011-06-27 9:41 UTC (permalink / raw)
To: guile-user
"Tomas By" <tomas@basun.net> writes:
> I have an extended Guile interpreter with a C function "get-map",
> defined by "scm_c_define_gsubr", that I then try to use in the
> (pure Scheme) module "mapdisplay", with the following result:
>
> [snip]
>
> Any ideas what is happening here? How can I debug it?
Having read the rest of this thread so far, I suggest that you put your
built-in functions into a module which can then be loaded by your pure
Scheme functions.
You need to do something like this:
static SCM
my_func (SCM arg)
{
/* ... blah blah ... */
}
static void
init_builtins_module ()
{
scm_c_define_gsubr ("my-func", 1, 0, 0, my_func);
scm_c_export ("my-func", NULL);
}
void
init_builtins ()
{
scm_c_define_module ("myapp builtins",
init_builtins_module,
NULL);
}
Then in your pure Scheme module, you can add:
(use-modules (myapp builtins))
I hope that helps.
Regards,
Peter
--
Peter Brett <peter@peter-b.co.uk>
Remote Sensing Research Group
Surrey Space Centre
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: "unbound variable"
2011-06-27 9:41 ` Peter Brett
@ 2011-06-27 21:44 ` Linas Vepstas
2011-06-28 6:15 ` Tomas By
0 siblings, 1 reply; 10+ messages in thread
From: Linas Vepstas @ 2011-06-27 21:44 UTC (permalink / raw)
To: Peter Brett; +Cc: guile-user
On 27 June 2011 04:41, Peter Brett <peter@peter-b.co.uk> wrote:
> "Tomas By" <tomas@basun.net> writes:
>
>> I have an extended Guile interpreter with a C function "get-map",
>> defined by "scm_c_define_gsubr", that I then try to use in the
>> (pure Scheme) module "mapdisplay", with the following result:
>>
>> [snip]
>>
>> Any ideas what is happening here? How can I debug it?
>
> Having read the rest of this thread so far, I suggest that you put your
> built-in functions into a module which can then be loaded by your pure
> Scheme functions.
Having used scm_c_define_gsubr in three different projects now, I'l
disagree .. never had to create a module to use it ...
Not sure what the bug is, though ... does get-map work
if you don't use it within the module? Can you verify it works
in some simple way?
--linas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: "unbound variable"
2011-06-27 21:44 ` Linas Vepstas
@ 2011-06-28 6:15 ` Tomas By
0 siblings, 0 replies; 10+ messages in thread
From: Tomas By @ 2011-06-28 6:15 UTC (permalink / raw)
To: guile-user
On Mon, June 27, 2011 23:44, Linas Vepstas wrote:
> Not sure what the bug is, though ... does get-map work
> if you don't use it within the module? Can you verify it works
> in some simple way?
yes it works fine, except from inside the module.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: "unbound variable"
2011-06-26 8:00 "unbound variable" Tomas By
2011-06-27 3:40 ` nalaginrut
2011-06-27 9:41 ` Peter Brett
@ 2012-01-08 17:04 ` Andy Wingo
2 siblings, 0 replies; 10+ messages in thread
From: Andy Wingo @ 2012-01-08 17:04 UTC (permalink / raw)
To: Tomas By; +Cc: guile-user
Hi,
You probably figured this one out, many moons ago, but:
On Sun 26 Jun 2011 10:00, "Tomas By" <tomas@basun.net> writes:
> | mapdisplay.scm:36:12: In expression (get-map wg name):
> | mapdisplay.scm:36:12: Unbound variable: get-map
> | ABORT: (unbound-variable)
> | guile> get-map
> | #<primitive-procedure get-map>
> | guile>
later you said:
> | guile> (apropos "get-map")
> | (guile-user): get-map #<primitive-procedure get-map>
> Any ideas what is happening here? How can I debug it?
The issue is that get-map was defined in guile-user. But that's not the
root module: it's only the default module at the REPL.
Your mapdisplay module implicitly imported (guile), not (guile-user).
When you are extending Guile, it's best to put primitives in their own
modules, as Peter mentioned.
Regards,
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2012-01-08 17:04 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-26 8:00 "unbound variable" Tomas By
2011-06-27 3:40 ` nalaginrut
2011-06-27 8:12 ` Tomas By
2011-06-27 8:38 ` nalaginrut
2011-06-27 8:56 ` Tomas By
2011-06-27 9:18 ` nalaginrut
2011-06-27 9:41 ` Peter Brett
2011-06-27 21:44 ` Linas Vepstas
2011-06-28 6:15 ` Tomas By
2012-01-08 17:04 ` Andy Wingo
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).