unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Re: Continuations: possible newbie question
@ 2002-12-18 18:42 Thien-Thi Nguyen
  2002-12-26 21:30 ` Found a bug in guile 1.6.0 Roland Orre
  0 siblings, 1 reply; 4+ messages in thread
From: Thien-Thi Nguyen @ 2002-12-18 18:42 UTC (permalink / raw)
  Cc: guile-user

   From: Matt Hellige <matt@immute.net>
   Date: Wed, 18 Dec 2002 12:14:10 -0600

   what I should do to
   submit a bug report

it's probably sufficient to send a message to bug-guile saying "see
thread ``Continuations: ...'' in guile-user".  the posted snippets are
fine as far as test-cases go.  (-; but this is not "official" policy.)

thi


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


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

* Found a bug in guile 1.6.0
  2002-12-18 18:42 Continuations: possible newbie question Thien-Thi Nguyen
@ 2002-12-26 21:30 ` Roland Orre
  2002-12-26 23:08   ` Marius Vollmer
  0 siblings, 1 reply; 4+ messages in thread
From: Roland Orre @ 2002-12-26 21:30 UTC (permalink / raw)


I found a bug when a let clause only contains a macro.
When the clause also contains a lambda clause it works.

The procedures iserror1 and iserror2 below gives the following error message:
      : In procedure cadr in expression (cadr x):
      : Wrong type argument in position 1: (#@push! stack vec)
but the procedure isworking below is working.

(define-public push!
  (procedure->macro
   (lambda(x env) `(set! ,(cadr x) (cons ,(caddr x) ,(cadr x))))))

(define stack '())

(define iserror1
  (lambda(size)
    (let ((vec (make-vector size #f)))
      (push! stack vec)
      vec)))

(define iserror2
  (lambda(size)
    (let ((vec (make-vector size #f)))
      ""
      (push! stack vec)
      vec)))

(define isworking
  (lambda(size)
    (let ((vec (make-vector size #f)))
      (lambda()#f)
      (push! stack vec)
      vec)))

(iserror1 1) 
(iserror2 1)
(isworking 1)

	Best regards
	Roland Orre



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


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

* Re: Found a bug in guile 1.6.0
  2002-12-26 21:30 ` Found a bug in guile 1.6.0 Roland Orre
@ 2002-12-26 23:08   ` Marius Vollmer
  0 siblings, 0 replies; 4+ messages in thread
From: Marius Vollmer @ 2002-12-26 23:08 UTC (permalink / raw)
  Cc: guile-user

Roland Orre <orre@nada.kth.se> writes:

> I found a bug when a let clause only contains a macro.
> When the clause also contains a lambda clause it works.

I don't think this is a bug in Guile, but a bug in the way you are
using procedure->macro.

The best solution is not to use procedure->macro.  Use define-macro
(or defmacro) or define-syntax.

'procedure->macro' does not generate what you probably think it does.
It creates a "non-memoizing macro", which is expanded everytime it is
executed.  The second time thru, tho, 'x' contains the internal form
of the macro invocation, which is not something that 'car' etc know
how to access.

You could try

  (define-macro (push! stack obj)
    `(set! ,stack (cons ,obj ,stack)))

but note that 'stack' is evaluated twice, which matters when you use
non-trivial setters/getters.

(Just curious: where did you learn about procedure->macro?  we don't
want people to use it.)

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


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

* Re: Found a bug in guile 1.6.0
  2002-12-26 23:50 ` Returned mail: see transcript for details Roland Orre
@ 2002-12-27  0:02   ` Roland Orre
  0 siblings, 0 replies; 4+ messages in thread
From: Roland Orre @ 2002-12-27  0:02 UTC (permalink / raw)


On Fri, 2002-12-27 at 00:08, Marius Vollmer wrote:
<snip>
>  The best solution is not to use procedure->macro.  Use define-macro
>  (or defmacro) or define-syntax.
<snip>

>  You could try
>    (define-macro (push! stack obj)
>      `(set! ,stack (cons ,obj ,stack)))
<snip>

Thanks, that macro definition works fine. I did, however, as this macro
is used in several places in my code, just convert it to a SCM_SYNTAX
which also solved the problem. The problem occured when I was checking
my old code for our recent conversion to guile 1.6. In most places the
old procedure->macro worked well though.

> (Just curious: where did you learn about procedure->macro?  we don't
> want people to use it.)

It's a remaining in my code from around 1990, long before guile, when I
was a heavily scm (which guile is based upon) user.

It seems as I should try to adapt to the new macros :)
Thanks once again!

        Best regards
        Roland



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


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

end of thread, other threads:[~2002-12-27  0:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-18 18:42 Continuations: possible newbie question Thien-Thi Nguyen
2002-12-26 21:30 ` Found a bug in guile 1.6.0 Roland Orre
2002-12-26 23:08   ` Marius Vollmer
     [not found] <200212262346.gBQNkaNc029823@smtp.nada.kth.se>
2002-12-26 23:50 ` Returned mail: see transcript for details Roland Orre
2002-12-27  0:02   ` Found a bug in guile 1.6.0 Roland Orre

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