CLIM mail archive

[Prev][Next][Index][Thread]

Wishful - Sequence presentation type standard change



    Date: Thu, 30 Jul 1992 13:32 EDT
    From: Curt Eggemeyer <curt@eraserhead.jpl.nasa.gov>

    I have found that I use the sequence presentation type a lot of times in
    situations that I wish it had an optional parameter(s) specifying length.

    This is only just a suggestion!

    I know can make my own subtype inheriting from sequence (already have),
    but has any of the CLIM creators gave much thought of standardizing that
    presentation type to utilize an optional length parameter for sequence,
    sort of like the string type.  It would make it a little more consistent
    in the base types CLIM provides.

Adding a length argument to the SEQUENCE presentation type would make it
inconsistent with the Common Lisp SEQUENCE type.  We have tried to avoid
this as much as possible throughout CLIM.

I propose you do this (if you haven't already):

 (define-presentation-type-abbreviation bounded-sequence (element-type length)
   `((sequence-enumerated ,@(make-list length :initial-element element-type))
     :separator ,separator :echo-space ,echo-space)
   :options ((separator #\,)
             (echo-space t)))

If you want it to be spiffier, you can make this change, too, which I
will include in CLIM 2.0:

 (in-package #+clim-1 :clim #+clim-2 :clim-internals)
 (define-presentation-method describe-presentation-type
                             ((type sequence-enumerated) stream plural-count)
   (declare (ignore plural-count))              ;it's too hard to handle
   (cond ((let ((type (first element-types)))
            (dolist (x (cdr element-types) t)
              (unless (equal x type)
                (return nil))))
          ;; Do this if all the element types are the same
          (format stream "~D " (length element-types))
          (describe-presentation-type 
            (car element-types) stream (length element-types)))
         (t
          (let ((position 0)
                (last (1- (length element-types))))
            (dolist (element-type element-types)
              (describe-presentation-type element-type stream 1)
              (unless (= position last)
                (write-string (if (= last 1) " " ", ") stream)
                (when (= (incf position) last)
                  (write-string "and " stream))))))))


References:

Main Index | Thread Index