From: Timothy H. <tim...@ma...> - 2002-06-18 17:14:26
|
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=20 > variable 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=20 compiler does not make use of much optimization or inlining. > Will the home-grown apply/n compile to as efficient code/bytecode as=20= > apply/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 > |