[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] is case-lambda expensive?
From: |
Kon Lovett |
Subject: |
Re: [Chicken-users] is case-lambda expensive? |
Date: |
Wed, 24 May 2006 09:57:07 -0700 |
On May 24, 2006, at 9:25 AM, Matthew David Parker wrote:
Hi I've got functions for my SDL layer that I want to put like this:
(define msdl.pixel
(case-lambda
(() (printf "(msdl.pixel x y rgb alpha [img])\n"))
((x y rgb alpha)
(R_msdl.pixel (int x) (int y) (int rgb) (int alpha) 0))
((x y rgb alpha img)
(R_msdl.pixel (int x) (int y) (int rgb) (int alpha)
img))))
This way the user can type in:
(msdl.pixel)
(msdl.pixel x y rgb alpha [img])
so that it's easy to see how to use the command. However, if there is
some program where the user wants to draw 1000 pixels quickly, will
the
case-lambda make it significantly slower?
Try ,x (case-lambda ...) w/ csi to see what code is actually
generated. Assuming you compile w/ (inline) this isn't too bad.
Are you sure you want to saddle all your public procedures w/ the
lambda docu? If you compile w/ the default debugging level it will
add lambda info for you.
Ex: (w/ csi)
#;1> (define (msdl.pixel x y rgb alpha #!optional (img 0)) 'foo)
#;2> (procedure-information msdl.pixel)
(msdl.pixel x y rgb alpha #!optional (img 0))
#;3> (msdl.pixel 3)
Error: too few arguments - received 1 but expected 4: #<procedure
(msdl.pixel x y rgb alpha #!optional (img 0))>
Call history:
<eval> (msdl.pixel 3) <--
And (w/ csc)
Error: too few arguments - received 1 but expected 4: #<procedure
(msdl.pixel x3 y4 rgb5 alpha6 . g27)>
Call history:
t1.scm: 3 msdl.pixel <--
Thanks,
Matt
(btw, "msdl" is just a temporary name, as there is already an
"msdl" for
SDL)
_______________________________________________
Chicken-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/chicken-users