A lisp oriented question - interning symbols for use in Maxima
Subject: A lisp oriented question - interning symbols for use in Maxima
From: Žiga Lenarčič
Date: Sun, 18 Oct 2009 19:12:34 +0200
Hi!
I'm writing a Maxima interface to CFFI (for using C libraries from
Maxima).
I have the following problem - I want to convert a lisp string into a
symbol representing a Maxima function which would be invoked by the
same 'string' from Maxima console.
Right now I use
(intern (concatenate 'string "$" string))
to get the symbol which should represent the maxima function.
I get the correct results for cases such as "HelloWorld" -> |
$HelloWorld| (then the function can be called from maxima with
'HelloWorld()').
However if I try non-mixed case strings I get an inverted result. So
a string like "mul2" gives me a symbol |$MUL2|, which from Maxima is
seen as 'MUL2' and not 'mul2' as I would want it to be.
What should I do to get the correct lisp symbol, so calling from
Maxima will look like the string I use?
Are there already any functions in Maxima I should use or how should
I roll my own?
On a side note, is there any interest for a foreign library interface
in Maxima? Of course it works only in CFFI supported lisps, so no GCL
support, sorry. I quickly compared the calling overhead by importing
the C function 'rand()' from 'libc' and compared it to Maxima's
function 'random' - calling C function from Maxima was faster, so I
guess the overhead is quite small (on SBCL at least).
Regards,
Ziga