[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-hackers] foreign-declare doesn't work with e.g. #<#END.
From: |
Peter Bex |
Subject: |
Re: [Chicken-hackers] foreign-declare doesn't work with e.g. #<#END. |
Date: |
Wed, 12 Sep 2012 15:26:39 +0200 |
User-agent: |
Mutt/1.4.2.3i |
On Wed, Sep 12, 2012 at 08:03:27AM -0500, Peter Danenberg wrote:
> It looks like foreign-declare doesn't work with multiline string
> constants with embedded expressions:
>
> (let ((program "R-test"))
> (foreign-code
> #<#END
> Rf_initEmbeddedR(4, (char*[]) {"#{program}",
> "--slave",
> "--vanilla",
> "--args"});
> END
> ))
>
> results in:
>
> Syntax error: in `foreign-code' - string expected
>
> Multiline string constants without embedded expressions work fine,
> however:
>
> (foreign-code
> #<<END
> Rf_initEmbeddedR(4, (char*[]) {"R-test",
> "--slave",
> "--vanilla",
> "--args"});
> END
> )
>
> Can this be considered a bug?
No, because these embedded expressions expand to code which dynamically
concatenates strings at runtime:
#;1> ,x (let ((program "R-test")) #<#END
"foo#{program}"
END
)
(##core#let
((program "R-test"))
(##sys#print-to-string (cons "\"foo" (cons program (cons "\"" '())))))
And foreign-code wants a string literal, at compile time.
Cheers,
Peter
--
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
is especially attractive, not only because it can be economically
and scientifically rewarding, but also because it can be an aesthetic
experience much like composing poetry or music."
-- Donald Knuth