[Larceny-users] Opaque Data Types Default Printer - Part Duex

Ray Racine ray.racine at comcast.net
Sat Dec 15 11:04:50 EST 2007


Awhile back I inquired as to the possibility of adding a default printer
to the ERR5RS records standard.

I'd like to follow up and now inquire as to whether Larceny does/will
support a default printer as a proprietary ERR5RS extension.

Here is a use case.  I'd like to define a new opaque data type thread,
which has a default printer like so.

  ;; thread record
  ;;
  ;; Invariants:
  ;;  * state is one of
  ;;      NEW         -- not yet started
  ;;      RUNNABLE    -- on run queue
  ;;      RUNNING     -- only the current task (note: not SRFI-18 state)
  ;;      BLOCKED     -- victim of a block
  ;;      TERMINATED  -- exited or was killed
  ;;  * critical #t if task must be rescheduled with interrupts disabled
  ;;  * the current task is never on the run queue.
  ;;  * dead tasks are never on *all-tasks*

  (define thread-rtd
    (let ((thread-rtd (make-rtd 'thread '#(id k state critical
                                               ;; srfi-18
                                               name specific
                                               end-result end-exception
                                               mutexes))))
      ;; Define a printer routine for when a thread is displayed.
       ((rtd-mutator (record-rtd thread-rtd) 'printer)
        thread-rtd
        (lambda (thread out)
          (display "#<thread \"" out)
          (display (string-append (thread-name thread) "-"
                                  (number->string (thread-id thread)))
out)
          (display "\">" out)))
      thread-rtd))

The above code dies with the following:


Error: Vector-length: (name slot-offsets printer record-size
hierarchy-vector hierarchy-depth r6rs? ...) is not a vector.
Entering debugger; type "?" for help.
debug> 

-----------------

Without a default printer the the thread type I'd see something like
this when I do a simple (display thread) :

> (with-threading (lambda () 3))
#<record thread> :: RUNNABLE
#<record thread> :: RUNNING
#<record thread> :: TERMINATED

; The run queue is empty.  Ending threading.

When I'd like something more along the lines of

> (with-threading "listener" (lambda () 3))
<thread "listener-1"> :: RUNNABLE
<thread "listener-1"> :: RUNNING
<thread "listener-1"> :: TERMINATED

---------------------------------------

Back to the question.
Can I define a default printer proc to an ERR5RS defined record?  I
understand that this would be a non-portable extension for Larceny.


Thanks,

Ray 




More information about the Larceny-users mailing list