[gambit-list] silex string-append problem

Marc Feeley feeley at iro.umontreal.ca
Fri Jan 13 14:56:35 EST 2012


On 2012-01-13, at 12:21 PM, Sascha Ziemann wrote:

> I try to write a lexer for ASN.1 using Silex and Gambit. It worked
> pretty well in the beginning but now I am a bit stuck because of the
> following error:
> 
> *** ERROR IN out-print-table-data, "silex/silex.scm"@4774.13 -- Number
> of arguments exceeds implementation limit
> (string-append
> "#"
> "("
> "("
> "70"
> " "
> "("
> "46"
> " "
> "("
> "32"
> " "
> "("
> "10"
> " "
> "("
> ...)
> 
> I am not sure if it is a problem with my lexer specification, with
> Silex or with Gambit. I have attached my lexer, my test program and
> the LDAP ASN.1 definition I am using for my tests.
> 
> Can anybody tell me who is causing the error and how this can be fixed?

Gambit has an upper limit on the number of arguments which can be passed in a function call.  The limit is 8192 arguments by default.  The limit is due to the way the stack is managed.  The limit can be changed by modifying the definition of ___MAX_NB_ARGS in lib/mem.h and recompiling Gambit :

#define ___MAX_NB_ARGS 8192

but there will be a limit whatever you choose.

In the particular case of Silex, there is a call (apply string-append x) where x is a list containing more than 8192 strings.  You can avoid this problem by using Gambit's append-strings procedure :

> (append-strings (list "a" "b" "c"))
"abc"
> (apply string-append (list "a" "b" "c"))
"abc"

Just replace (apply string-append x) with (append-strings x).

Marc




More information about the Gambit-list mailing list