RE: How to extend a function?

Subject: RE: How to extend a function?
From: Avi Kivity <Avi@xxxxxxxxxxxxx>
Date: Tue, 2 Mar 1999 14:27:26 +0200
On Tuesday, March 02, 1999 14:03, Norman Walsh [SMTP:ndw@xxxxxxxxxx] wrote:
> | Assumed the style sheet had something like
> | 
> | (define (xyz a)
> |  (cond
> |   ((equal? a "X") #f)
> |   (else #t)))
> | 
> | Now I want to "use" that style sheet and say
> | 
> | (define (xyz a)
> |  (cond
> |   ((equal? a "Y") #f)
> |   (else (xzy a))))
> | 
> | The last call should go to the first definition.  Possible?
> 
> I don't think so. But, if you can frame the problem in terms of
> construction rules, you can call next-match.
> 
> For example, if you wanted to put square brackets around commands,
> but you wanted the presentation of commands otherwise unchanged,
> you could put the following in your stylesheet:
> 
> (element command
>   (make sequence
>     (literal "[")
>     (next-match)
>     (literal "]")))
> 

Wouldn't this work only if there were no other (element command ...) rules
in the stylesheet? which would make (next-match) a synonym of
(process-children).

(next-match) helps when you want to specify formatting of a specific case in
terms of the general case, but in your example the general case uses
(next-match) which can only match the default rule (or a rule in the default
mode?)

For extending a function, you can always use the time-honored

(define (xyz-orig) ...)

(define (xyz)
   ...
   (xyz-orig)
   ...
)
.

---
"The only words which have meaning are the last ones spoken"


 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread