[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] can you believe it? compile time vs. run time issues
From: |
felix winkelmann |
Subject: |
Re: [Chicken-users] can you believe it? compile time vs. run time issues, again! |
Date: |
Sun, 29 May 2005 12:20:27 +0200 |
On 5/29/05, Michele Simionato <address@hidden> wrote:
> How many times I have been bitten by compile-time vs. run-time issues?
> 10, 12? One would think I had understood the lesson, however ... :-(
>
> My motivation here was a nifty trick to generate dynamics records
> without using macros:
>
Very nifty. But the use of `eval' at runtime usually indicates
problems when compiling.
Ok, the correct way is this:
(declare (run-time-macros)) ; make sure macro expanders are
available at run-time
(require-extension match) ; make sure match-support (is needed by
match expanders) is linked
(include "chicken-match-macros.scm") ; include the macro-defs for match...
(include "chicken-more-macros.scm") ; include the macro-defs for cut
(define (dynamic-record ...) ...)
The syntax available for `eval' is deliberately restricted: usuall one doesn't
need all the extra macro-expanders. But if you need eval with all the extra
stuff, you might want to put the above code (minus def dynamic-record)
into an extra-file, say bigeval.scm, and install it as an extension:
chicken-setup bigeval
>From now on you can just say `(require-extension bigeval)' and you
will have all the extra macros available at run-time.
Actually, this could be turned into an egg...
>
> $ csc -run-time-macros dynamic-record.scm
> /usr/lib/gcc-lib/i486-linux/3.3.5/../../../crt1.o(.text+0x18): In
> function `_start':
> ../sysdeps/i386/elf/start.S:98: undefined reference to `main'
> collect2: ld returned 1 exit status
> *** Shell command terminated with exit status 1: gcc -o dynamic-record
> dynamic-record.o -lchicken -lsrfi-chicken -lstuffed-chicken
> -L/usr/local/lib -Wl,-R/usr/local/lib -ldl -lpcre -lm -ldl -lpcre
I didn't get this error. Did you add a unit declaration somewhere?
cheers,
felix