unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* What's with `symbol-set!' is deprecated. Use the module system instead.
@ 2011-12-04 15:37 David Kastrup
  2011-12-04 16:01 ` David Kastrup
  0 siblings, 1 reply; 6+ messages in thread
From: David Kastrup @ 2011-12-04 15:37 UTC (permalink / raw)
  To: guile-devel


The module system documentation provides _no_ _clue_ _whatsoever_ about
how something like
(symbol-set! #f (string->symbol name) value)
could be replaced.  In fact, the module system documentation provides
_no_ _clue_ _whatsoever_ how to actually access module variables short
of calling eval on little programs working with symbols.

I don't want to call eval for the simple act of setting a symbol to a
value.

The funny thing is that symbol-fset! and symbol-pset! are documented.
But nothing whatsoever that could set a symbol value itself on a symbol
that has been generated.

What's up with that?

-- 
David Kastrup




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

* Re: What's with `symbol-set!' is deprecated. Use the module system instead.
  2011-12-04 15:37 What's with `symbol-set!' is deprecated. Use the module system instead David Kastrup
@ 2011-12-04 16:01 ` David Kastrup
  2011-12-05  8:11   ` David Kastrup
  0 siblings, 1 reply; 6+ messages in thread
From: David Kastrup @ 2011-12-04 16:01 UTC (permalink / raw)
  To: guile-devel

David Kastrup <dak@gnu.org> writes:

> The module system documentation provides _no_ _clue_ _whatsoever_ about
> how something like
> (symbol-set! #f (string->symbol name) value)
> could be replaced.  In fact, the module system documentation provides
> _no_ _clue_ _whatsoever_ how to actually access module variables short
> of calling eval on little programs working with symbols.
>
> I don't want to call eval for the simple act of setting a symbol to a
> value.
>
> The funny thing is that symbol-fset! and symbol-pset! are documented.
> But nothing whatsoever that could set a symbol value itself on a symbol
> that has been generated.
>
> What's up with that?

Well, I disassembled enough to come up with
(module-define! (current-module) (string->symbol name) value)

It is not like there is _any_ documentation for this in the manual.

Is this somebody's idea of a joke?

-- 
David Kastrup




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

* Re: What's with `symbol-set!' is deprecated. Use the module system instead.
  2011-12-04 16:01 ` David Kastrup
@ 2011-12-05  8:11   ` David Kastrup
  2011-12-05 14:54     ` Andy Wingo
  0 siblings, 1 reply; 6+ messages in thread
From: David Kastrup @ 2011-12-05  8:11 UTC (permalink / raw)
  To: guile-devel

David Kastrup <dak@gnu.org> writes:

> David Kastrup <dak@gnu.org> writes:
>
>> The module system documentation provides _no_ _clue_ _whatsoever_ about
>> how something like
>> (symbol-set! #f (string->symbol name) value)
>> could be replaced.  In fact, the module system documentation provides
>> _no_ _clue_ _whatsoever_ how to actually access module variables short
>> of calling eval on little programs working with symbols.
>>
>> I don't want to call eval for the simple act of setting a symbol to a
>> value.
>>
>> The funny thing is that symbol-fset! and symbol-pset! are documented.
>> But nothing whatsoever that could set a symbol value itself on a symbol
>> that has been generated.
>>
>> What's up with that?
>
> Well, I disassembled enough to come up with
> (module-define! (current-module) (string->symbol name) value)
>
> It is not like there is _any_ documentation for this in the manual.
>
> Is this somebody's idea of a joke?

Apparently.  The C interface offers scm_define which works fine for this
purpose.  But on the Scheme side, there is _no_ equivalent to Lisp's set
(rather than setq or setf).  What is one supposed to do?

(define-macro (mydef! name . rest) `(define ,(primitive-eval name) ,@rest))

Is this supposed to be a puzzle?  Why is there _no_, I repeat _no_
documented way of setting a symbol that is not given literally to a
value?  Neither in the straight way (as with C's scm_define which is a
function rather than a macro and thus useful for this purpose), nor in
connection with modules (since neither module-define! nor module-set!
are documented anywhere).

-- 
David Kastrup




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

* Re: What's with `symbol-set!' is deprecated. Use the module system instead.
  2011-12-05  8:11   ` David Kastrup
@ 2011-12-05 14:54     ` Andy Wingo
  2012-01-06 23:47       ` Andy Wingo
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Wingo @ 2011-12-05 14:54 UTC (permalink / raw)
  To: David Kastrup; +Cc: guile-devel

Hello David,

On Mon 05 Dec 2011 09:11, David Kastrup <dak@gnu.org> writes:

> David Kastrup <dak@gnu.org> writes:
>
>>> (symbol-set! #f (string->symbol name) value)
>> (module-define! (current-module) (string->symbol name) value)

Indeed, the module system needs better documentation.

>> Is this somebody's idea of a joke?

It might be!  I personally can't say though, as things have been this
way for longer than my time in Guile.

> Apparently.  The C interface offers scm_define which works fine for this
> purpose.

Yes.  Version 2.0.x has better-documented interfaces, here:

  http://www.gnu.org/software/guile/manual/html_node/Accessing-Modules-from-C.html

The Scheme equivalents are not documented as well, however.  Definitely
a bug, there.

Regards,

Andy
-- 
http://wingolog.org/



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

* Re: What's with `symbol-set!' is deprecated. Use the module system instead.
  2011-12-05 14:54     ` Andy Wingo
@ 2012-01-06 23:47       ` Andy Wingo
  2012-01-07  9:10         ` David Kastrup
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Wingo @ 2012-01-06 23:47 UTC (permalink / raw)
  To: David Kastrup; +Cc: guile-devel

Hi,

On Mon 05 Dec 2011 15:54, Andy Wingo <wingo@pobox.com> writes:

> On Mon 05 Dec 2011 09:11, David Kastrup <dak@gnu.org> writes:
>
>> David Kastrup <dak@gnu.org> writes:
>>
>>>> (symbol-set! #f (string->symbol name) value)
>>> (module-define! (current-module) (string->symbol name) value)
>
> Indeed, the module system needs better documentation.

I have now documented module-define! and some related procedures.

Regards,

Andy
-- 
http://wingolog.org/



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

* Re: What's with `symbol-set!' is deprecated. Use the module system instead.
  2012-01-06 23:47       ` Andy Wingo
@ 2012-01-07  9:10         ` David Kastrup
  0 siblings, 0 replies; 6+ messages in thread
From: David Kastrup @ 2012-01-07  9:10 UTC (permalink / raw)
  To: guile-devel

Andy Wingo <wingo@pobox.com> writes:

> Hi,
>
> On Mon 05 Dec 2011 15:54, Andy Wingo <wingo@pobox.com> writes:
>
>> On Mon 05 Dec 2011 09:11, David Kastrup <dak@gnu.org> writes:
>>
>>> David Kastrup <dak@gnu.org> writes:
>>>
>>>>> (symbol-set! #f (string->symbol name) value)
>>>> (module-define! (current-module) (string->symbol name) value)
>>
>> Indeed, the module system needs better documentation.
>
> I have now documented module-define! and some related procedures.

I am glad to hear it.

-- 
David Kastrup




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

end of thread, other threads:[~2012-01-07  9:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-04 15:37 What's with `symbol-set!' is deprecated. Use the module system instead David Kastrup
2011-12-04 16:01 ` David Kastrup
2011-12-05  8:11   ` David Kastrup
2011-12-05 14:54     ` Andy Wingo
2012-01-06 23:47       ` Andy Wingo
2012-01-07  9:10         ` David Kastrup

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).