On Thu, 06 Apr 2000 15:20:32 PDT, the world broke into rejoicing as
Dave Peticolas <[EMAIL PROTECTED]>  said:
> 
> Right now, reports are represented in guile as a vector
> containing a version, name, option generator, and renderer.
> Some things I'd like to add in the future include a help
> text generator, and report-specific toolbar buttons and
> menu items. To eliminate the need to change each report
> every time we add a new feature, I'd like to move the
> report representation to the "key->value" style scheme
> closure.
> 
> Any thoughts?

I'd suggest making it into a Guile "record," in much the way the
budget report uses them.

It is indeed a bad thing to have all the parameters addressed
implicitly by position; I would be a *VERY* happy camper if Guile
offered something equivalent to the Common Lisp idea where you
define a function thus:

  (defun complex-function (&rest title version options renderer)
    ;;; code
   )
which would be called thus:
   (complex-function :title "Budget" :version 1.5 :renderer #'budrend)

Note that here I didn't bother passing in a value for :options, and
so there is no value...

[CL offers further control over this, allowing a default value to be
 defined, but that heads down a pointless road...]

The nearest equivalent in Scheme would be to define the function
thus:
(define (make-report . args)
   (let ((report-defn (args-to-defn #f args)))
    ;;; On to the body...
   )

where we'd need, to "parse" the arguments:
(define (args-to-defn input-record arglist)
   (let ((inrec (if input-record
                    input-record
                    ((record-constructor report-record-structure)
                     #f #f #f #f #f #f #f))))
     (if arglist
        (let ((id (car arglist))
              (value (cadr arglist))
              (remainder (cddr arglist)))
           ((record-modifier report-record-structure id)
            inrec value)
           (args-to-defn inrec remainder))
        inrec)))

I would suppose that to construct a report "record" you'd probably
use the following:
(define budget-report
       (args-to-defn #f 'version 2.5 'name "Budget"
                        'options 
                            (lambda ())  ;;; Some complex function
                        'renderer
                            budget-render-function))


If you add another "option" to the report-record-structure, this
means that the existing reports don't use that option; it could
be meaningful to have the function that *reads* out of that record
gripe, in a not-too-unfriendly way, about the slot being left
blank...

[Aside: I find that when I am wondering how to implement something,
it is a *remarkably* useful idea to look to Common Lisp.  The designers
hashed through more complex issues with *reasonable* success than just
about any other computer language.  If you want to build a date library,
look at the HyperSpec.  If you're not sure how to implement a mathematical
function, look at the HyperSpec.  They may well explain why the option
that comes to mind first is actually a very BAD idea...]
--
When I die, I'd like to go peacefully in my sleep like my grandfather,
not screaming in terror like his passengers...
[EMAIL PROTECTED] - <http://www.ntlug.org/~cbbrowne/lsf.html>

--
Gnucash Developer's List 
To unsubscribe send empty email to: [EMAIL PROTECTED]


Reply via email to