schemer7rs

Gensym procedure with larceny r7rs


Under larceny r7r6 for scheme, I am trying to use the gensym procedure as it is apparently defined in the documentation.

When calling it (either in file or in console by typing larceny -r7r6), I get an error message saying that gensym is an undefined global variable.

Did I forget an import or is it not available ? Is there a new name or an implementation I can find anywhere ?


Solution

  • gensym procedure is defined in neither R6RS or R7RS. So you need to import it separately if you want to use it in the R6RS/R7RS environment like this:

    (import (primitives gensym))
    

    It might be better to use the generate-temporaries procedure which is defined in (rnrs) returning a list of temporary identifiers. You can use it to generate a fresh symbol like this

    (apply syntax->datum (generate-temporaries '(a)))
    

    This would return a list which contains only one symbol as its element.