From: Ken A. <kan...@bb...> - 2002-06-18 18:01:59
|
I've found this version of apply annoying myself. I've just checked in changes so that apply now takes 1 or more arguments,= =20 the last of which must be a list. I have not changed the documentation. BTW, Tim, your definition of list* relies on (null? (rest '()) -> #t which it is in Jscheme, but it is an error in Scheme in general. k At 01:14 PM 6/18/2002, Timothy Hickey wrote: >On Tuesday, June 18, 2002, at 03:57 AM, Hoehle, Joerg-Cyril wrote: > >>Hi, >> >>apply in Jscheme takes exactly 2 arguments. >>>apply >>{jsint.Primitive apply[2]} >> >>In R4RS terms: >> essential procedure: apply proc args >> procedure: apply proc arg1 ... args >>, this means that only the essential part if implemented in Jscheme. >> >>R5RS' apply takes n arguments and doesn't make a distinction anymore.=20 >>Having only apply/2 is a nightmare for recursive procedures with variab= le=20 >>number of arguments. >> >>BTW, the documentation at >>http://jscheme.sourceforge.net/jscheme/doc/R4RSprimitives.html >>is inconsistent. It says >>(apply f arguments ) ... >>(map F L) ... >>Yet map takes n arguments (in both R4RS and R5RS and) in Jscheme. >> >> >>While it is a trivial exercise to write an apply/n based on the apply/2= , > >You can load in a file newapply.scm that redefines apply: > >(set! apply > (let ((ap apply)) > (letrec ((list*(lambda (R) (if (null? (rest R)) (first R) (cons=20 > (first R) (list* (rest R))))))) > (lambda (f . R) > (ap f (list* R)))))) > > >> it is not so w.r.t. compiler optimization and inlining. >For the future this may be an issue. For the moment, the Jscheme compile= r=20 >does not >make use of much optimization or inlining. > >>Will the home-grown apply/n compile to as efficient code/bytecode as ap= ply/2? >For now yes, but in the future no. >> >>BTW, Common Lisp has list* which is quite useful for a straightforward=20 >>apply/n->apply/2. > >You have a point, perhaps we should add list* and apply/n to Jscheme... >---Tim--- > >> >>Regards, >> J=F6rg H=F6hle. >>Using Jscheme 5.0 04/05/2002 on MS-Woes-2000 >> >>-----------------------------------------------------------------------= ----- >> Bringing you mounds of caffeinated joy >>>>> http://thinkgeek.com/sf <<< >> >>_______________________________________________ >>Jscheme-user mailing list >>Jsc...@li... >>https://lists.sourceforge.net/lists/listinfo/jscheme-user > > >------------------------------------------------------------------------= ---- > Bringing you mounds of caffeinated joy > >>> http://thinkgeek.com/sf <<< > >_______________________________________________ >Jscheme-user mailing list >Jsc...@li... >https://lists.sourceforge.net/lists/listinfo/jscheme-user > |