Re: [Chicken-users] How do I name these procedures?
2010/4/15 Jeronimo Pellegrini : > [...] > I wonder if the optional argument would make the function call too much > slower? > [...] Hello Jeronimo, the optional argument processing will take a little time, but whether that is relevant should be determined by a benchmark. > [...] > But there's a difference between these two: > > ia+ia (sums two intervals) > ia+f64 (sums an interval to a flonum) > > Using only ia+ would mean checking the type inside the procedure, which > I'd like to avoid. > [...] To avoid duplication of name parts I would probably still call the sum of two intervals just ia+. ia+f64 sounds fine to me, but unless there is also ia+f32 or something similar, I might consider to use something like ia-shift. In the end it's all up to you and anybody who doesn't like the names can always use a renaming import when accessing your egg :-) Ciao, Thomas -- When C++ is your hammer, every problem looks like your thumb. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] qt & dbus eggs
On Wed, Apr 7, 2010 at 10:08 PM, Andrei Barbu wrote: >>> I'm working on getting chicken into shape for writing applications on >>> the Nokia N900. I've made a lot of changes to the qt egg over the past That sounds like fun! I would like to go that direction some day too, but not just yet... too much going on. I'm sorry I still didn't get the qt egg ported to chicken 4. It worked pretty well with chicken 3. (You can always downgrade to get all the eggs that haven't been ported yet. I still use chicken 3 for just that reason.) ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] How do I name these procedures?
On Thu, Apr 15, 2010 at 10:33:51PM +0200, Thomas Chust wrote: > Hello Jeronimo, > > thinking about it, I would only provide two wrappers per function: One > destructive version that accepts two mandatory input arguments and an > optional output argument defaulting to the first input argument. And > one non-destructive version that accepts just the two input > arguments and allocates an output target. > > The code would look like this: > > (define (ia+! a b #!optional [out a]) > ((foreign-lambda void "mpfi_add" c-pointer c-pointer c-pointer) > out a b) > out) OK, that sounds much better! I wonder if the optional argument would make the function call too much slower? > (define (ia+ a b) > (ia+! a b (make-ia-interval))) > I would also just prefix the operator names with characters, not > suffix them — mostly because of the stylistic similarity to existing > bindings like fx+. But there's a difference between these two: ia+ia (sums two intervals) ia+f64 (sums an interval to a flonum) Using only ia+ would mean checking the type inside the procedure, which I'd like to avoid. J. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] qt & dbus eggs
On Thu, Apr 15, 2010 at 1:54 PM, Shawn Rutledge wrote: > I'm sorry I still didn't get the qt egg ported to chicken 4. It I mean the dbus egg. I didn't have anything to do with the qt egg so far. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] How do I name these procedures?
2010/4/15 Jeronimo Pellegrini : > [...] > Most mpfi functions receive pointer to structures that represent > intervals, and the return value is the first argument: > > mpfi_add (a, b, c); /* This is a <- b + c */ > > When translating this into Scheme, I thought I'd offer > three versions of each function. For example, the function > mpfi_add, which sums intervals, would generate: > > (ia+ia!! a b c) ; same as mpfi (a, b, c) > > (ia+ia! a b) ; defined as (ia+ia!! a a c) > ; a will be overwritten > > (ia+ia a b) ; allocates a new structure x and > ; does (ia+ia!! x a b) > ; See below: > [...] Hello Jeronimo, thinking about it, I would only provide two wrappers per function: One destructive version that accepts two mandatory input arguments and an optional output argument defaulting to the first input argument. And one non-destructive version that accepts just the two input arguments and allocates an output target. The code would look like this: (define (ia+! a b #!optional [out a]) ((foreign-lambda void "mpfi_add" c-pointer c-pointer c-pointer) out a b) out) (define (ia+ a b) (ia+! a b (make-ia-interval))) I would also just prefix the operator names with characters, not suffix them — mostly because of the stylistic similarity to existing bindings like fx+. Ciao, Thomas -- When C++ is your hammer, every problem looks like your thumb. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Explicit renaming macros behavior during interpretation and compilation
On Thu, Apr 15, 2010 at 03:40:01PM +0200, Thomas Chust wrote: > Hello Jeronimo, Hi Thomas! > the environment in which syntax transformers are run is distinct from > the one in which the compiled code is eventually run. You probably > want to use define-for-syntax instead of define to introduce your > helper procedure into the environment for syntax transformers. Thanks a lot, that's what I needed. J. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] How do I name these procedures?
Hi, I'm working on bindings for a library (MPFI, a C library for interval arithmetic [0]), which I'd like to make available as an egg. Most mpfi functions receive pointer to structures that represent intervals, and the return value is the first argument: mpfi_add (a, b, c); /* This is a <- b + c */ When translating this into Scheme, I thought I'd offer three versions of each function. For example, the function mpfi_add, which sums intervals, would generate: (ia+ia!! a b c) ; same as mpfi (a, b, c) (ia+ia! a b); defined as (ia+ia!! a a c) ; a will be overwritten (ia+ia a b) ; allocates a new structure x and ; does (ia+ia!! x a b) ; See below: (define (ia+ia a b) (let ((x (make-ia-interval))) (ia+ia!! x a b) x)) I am using the "ia" prefix/suffix to mean "interval arithmetic", since there will also be functions like "ia+f64!"; also, I may also in the future make bindings for affine arithmetic libraries[1] -- which will then be named "aa+aa!", and so on. I'd like some opinions on the naming of these procedures. Since there are two mutating procedures for each C function, I would use "!" in one of them and "!!" in another (and I thought it'd be better to use "!!" on the one likely to be the least used one). But I'm not really comfortable with this ! and !! idea... Any comments? Thanks, J. [0] MPFI: http://cadadr.org/fm/package/mpfi.html (but right now the site seems to be down) [1] Affine arithmetic: http://en.wikipedia.org/wiki/Affine_arithmetic http://www.ic.unicamp.br/~stolfi/EXPORT/projects/affine-arith/Welcome.html ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Explicit renaming macros behavior during interpretation and compilation
2010/4/15 Jeronimo Pellegrini : > [...] > This program seems to work fine when loaded from csi, but csc > complains that a procedure used inside the renaming procedure > is unbound (even though it was defined shortly before the > macro definition): > [...] Hello Jeronimo, the environment in which syntax transformers are run is distinct from the one in which the compiled code is eventually run. You probably want to use define-for-syntax instead of define to introduce your helper procedure into the environment for syntax transformers. Ciao, Thomas -- When C++ is your hammer, every problem looks like your thumb. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] Explicit renaming macros behavior during interpretation and compilation
Hello, I understand syntax-rules and Common Lisp's defmacro, but I'm still getting acquainted with Chicken's implementation of explicitly renaming macros. So far I have had success in writing simple macros, but there's one thing I don't understand. This program seems to work fine when loaded from csi, but csc complains that a procedure used inside the renaming procedure is unbound (even though it was defined shortly before the macro definition): /--- ;; macro.scm (a silly artificial example) ;; swaps the two first elements of a list (define change-sexp (lambda (sexp) (append (list (cadr sexp) (car sexp)) (cddr sexp ;; swaps the two first arguments of a procedure call (define-syntax swap-args (lambda (expr ren cmp) `(,(caadr expr) ,@(change-sexp (cdadr expr) (display (expand '(swap-args (/ 1 2 3 (newline) (display (swap-args (/ 1 2 3))) (newline) \--- $ csi -q #;1> (load "macro.scm") ; loading macro.scm ... (/ 2 1 3) 0.667 #;2> $ csc macro.scm Error: during expansion of (swap-args ...) - unbound variable: change-sexp Call history: (##core#begin (display (swap-args (/ 1 2 3 (display (swap-args (/ 1 2 3))) (swap-args (/ 1 2 3)) (##sys#cons (caadr expr) (##sys#append (change-sexp (cdadr expr)) (##core#quote ( (caadr expr) (##sys#append (change-sexp (cdadr expr)) (##core#quote ())) (change-sexp (cdadr expr)) <-- Error: shell command terminated with non-zero exit status 17920: /usr/local/bin/chicken macro.scm -output-file macro.c Is it not possible to use auxiliary procedures when defining renaming macros in compiled code? Thanks, J. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] qt & dbus patches
Andrei Barbu schrieb: Hi, The patch to the qt egg is at http://0xab.com/patches/qt-0.100.patch The build system for the svn version is hopelessly broken on my machines (a fairly standard Gentoo amd64, and a standard Debian Lenny install), so I replaced it with the one that I'm using. I'm willing to bet that this breaks building on Windows. A quick note while I'm at it: (define prefix (program-path)) (define binpath (make-pathname prefix "bin")) ;; Note that binpath points to the wrong location on my system (define csc (make-pathname "/usr/bin/" ;; binpath "csc")) I wonder why that is. dbus ported to v4 is a ' git clone http://0xab.com/repos/chicken-dbus.git ' away. You should be able to add that to the repository after removing the debian directory. Thanks, Andrei! I have to check this out (and this may take a while). We should put this into a temporary branch in the svn repo. If you want, you can get commit access. cheers, felix ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users