John Bignucolo
2017-01-05 12:17:53 UTC
Greetings,
As an exercise, I tried to use the '-r7rs' and '-program' options to
larceny to implement something really simple: a Scheme version of echo. Eg,
â
$ time larceny -r7rs -program echo.sps -- a b c
a b c
real 0m1.083s
user 0m1.064s
sys 0m0.012s
âThis was with Larceny v0.99 "Goldie" (May 25 2016 01:16:34,
precise:Linux:unified)
larceny.heap, built on Wed May 25 01:17:00 EDT 2016
I
â ran into a problem when I tried to change the program to use the
string-join function from SRFI-13.
The '-r7rs' '-program' options require that you import everything you need.
Since string-join is part of SRFI-13 I thought all I needed to do was:
(import (scheme base)
(scheme load)
(scheme write)
(scheme process-context)
(srfi 13))
;; skip over 'larceny' as arg0
(let ((prog-args (cdr (command-line))))
(if (not (null? prog-args))
(display (string-join prog-args))))
(newline)
But this generated an error:
Syntax violation: import
Different bindings for identifier imported from libraries () and (srfi :13
strings)
Form: string-for-each
Trace:
Error: unhandled condition:
Compound condition has these components:
#<record &who>
who : import
#<record &message>
message : "Different bindings for identifier imported from libraries ()
and (srfi :13 strings)"
#<record &syntax>
form : string-for-each
subform : #f
Entering debugger; type "?" for help.
I was able to able to get it work by changing the srfi import definition to
be:
(only (srfi 13) string-join)
But this resulted in a five-fold increase in runtime, due I assume, to a
longer startup time required to find string-join:
$ time larceny -r7rs -program echo.sps -- a b c
a b c
real 0m5.036s
user 0m5.008s
sys 0m0.020s
Was I wrong in using (srfi 13) in the import list?
What is the correct method for importing SRFI-13 (or other libraries) that
have names that clash with those defined in (scheme base)?
Regards,
John
As an exercise, I tried to use the '-r7rs' and '-program' options to
larceny to implement something really simple: a Scheme version of echo. Eg,
â
$ time larceny -r7rs -program echo.sps -- a b c
a b c
real 0m1.083s
user 0m1.064s
sys 0m0.012s
âThis was with Larceny v0.99 "Goldie" (May 25 2016 01:16:34,
precise:Linux:unified)
larceny.heap, built on Wed May 25 01:17:00 EDT 2016
I
â ran into a problem when I tried to change the program to use the
string-join function from SRFI-13.
The '-r7rs' '-program' options require that you import everything you need.
Since string-join is part of SRFI-13 I thought all I needed to do was:
(import (scheme base)
(scheme load)
(scheme write)
(scheme process-context)
(srfi 13))
;; skip over 'larceny' as arg0
(let ((prog-args (cdr (command-line))))
(if (not (null? prog-args))
(display (string-join prog-args))))
(newline)
But this generated an error:
Syntax violation: import
Different bindings for identifier imported from libraries () and (srfi :13
strings)
Form: string-for-each
Trace:
Error: unhandled condition:
Compound condition has these components:
#<record &who>
who : import
#<record &message>
message : "Different bindings for identifier imported from libraries ()
and (srfi :13 strings)"
#<record &syntax>
form : string-for-each
subform : #f
Entering debugger; type "?" for help.
I was able to able to get it work by changing the srfi import definition to
be:
(only (srfi 13) string-join)
But this resulted in a five-fold increase in runtime, due I assume, to a
longer startup time required to find string-join:
$ time larceny -r7rs -program echo.sps -- a b c
a b c
real 0m5.036s
user 0m5.008s
sys 0m0.020s
Was I wrong in using (srfi 13) in the import list?
What is the correct method for importing SRFI-13 (or other libraries) that
have names that clash with those defined in (scheme base)?
Regards,
John
--
John Bignucolo
***@gmail.com
John Bignucolo
***@gmail.com