Misc. questions and bugs

From: Ben L. Di Vito <bld_at_air57.larc.nasa.gov>
Date: Fri, 4 Jun 1999 09:37:01 -0400 (EDT)

I've been trying out various things with STk and have a few questions
about specific features:

 - Is there a direct way to extract the lambda arguments of a procedure?
   I know I can apply procedure-body and then take the cadr of it, but I
   was concerned about possible overhead with large procedures. Is the
   value returned by procedure-body already lying around as the value of
   the lambda, or does it have to be reconstructed from an internal form?

 - I noticed that applying force to non-promise values just returns the
   value. This is good. I like that convention, but it differs from
   other Schemes that produce an error in this case. Can we assume the
   STk convention will work for all non-promise values?

 - When an error occurs and report-error is invoked, what kind of
   continuation is in effect? Is it the same as if we had returned to
   the top level and then called report-error, or are we deeply nested
   at the point where the error occurred? If an error occurs within
   a Tk event handler, is a TclRelease or other necessary Tk cleanup
   performed before calling report-error?

And now for a few bugs I ran into recently. These occurred in 3.99.4
on a Linux box.

 - (list-tail '() 0) ==> error: bad list

 - (bind w <event>) produces an error when a nonnull binding exists.
   A null binding returns "" as the value. In Tcl/Tk this form gives
   the bindings that are in effect for the event. Is this form of the
   bind procedure implemented in STk?

 - The use of generic procedures to implement recognizer predicates for
   STklos objects didn't work for me. Consider:

     (define-class obj () ((comp1 :initform 0)))
     (define-method obj? (x <obj>) #t)

   Evaluating (obj? (make obj)) produces the error "no applicable
   generic procedure ...". After supplying the other case:

     (define-method obj? (x) #f)

   the error goes away but every value invokes the false predicate.

     (obj? (make obj)) ==> #f
     (obj? 7) ==> #f

 - STklos objects do make the procedure? predicate true, however.

     (procedure? (make obj)) ==> #t

   I don't know if this makes sense with respect to the internal
   representation, but it seems inconsistent with Scheme semantics
   because you can't apply such an object as a procedure.

 - Another predicate with a problem is continuation?. It doesn't
   seem to recognize continuations and always returns false.

     (call/cc (lambda (p) (continuation? p))) ==> #f

 - A bigger continuation problem occurs with dynamic-wind. It fails
   to invoke the third thunk when a continuation is called. See the
   following code.

     (define cont1 #f)
     (define cont2 #f)

     (define (dspl str)
       (display str)
       (newline) )

     (let ((val (call/cc (lambda (proc)
                  (set! cont1 proc)
                  1 ))))
       (display "Result = ")
       (dspl val)
       (when cont2 (cont2 #f)) )

     (define (test1 d)
       (dynamic-wind
         (lambda () (dspl "Thunk 1: entering extent"))
         (lambda () (dspl "Invoking continuation")
                    (call/cc (lambda (proc)
                      (set! cont2 proc)
                      (dspl (cont1 (/ d))) ))
                    (dspl "We're back") )
         (lambda () (dspl "Thunk 3: leaving extent")) ))

   Evaluating these definitions and invoking test1 results in:

     STk> (test1 5)
     Thunk 1: entering extent
     Invoking continuation
     Result = 0.2
     Thunk 1: entering extent
     We're back
     Thunk 3: leaving extent

     STk> (test1 0)
     Thunk 1: entering extent
     Invoking continuation

     *** Error:
     /: not a valid number: 0
     Thunk 3: leaving extent

   Notice that thunk-3 did not get called in the first test when
   (externally captured) continuation cont1 was invoked, thereby
   leaving the dynamic extent.

And finally, let me just point out that "the third thunk" would be an
excellent name for a rock band. (For non-American readers, this is a
variation on a theme by humor columnist Dave Barry.)

Regards,
Ben

---
    Ben Di Vito                     b.l.divito_at_larc.nasa.gov
    1 South Wright Street, MS 130   http://shemesh.larc.nasa.gov/~bld
    NASA Langley Research Center    voice: +1-757-864-4883
    Hampton, VA 23681   USA         fax:   +1-757-864-4234
Received on Fri Jun 04 1999 - 15:31:50 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST