mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-17 16:21:46 +03:00
cff5fc2625
Racket appears to have a different notion of current directory than the system does, so we need to tell it which directory we think we're in when reading and writing bytevectors using the scheme file functions.
43 lines
1.0 KiB
ReStructuredText
43 lines
1.0 KiB
ReStructuredText
****************************
|
|
Gambit Scheme Code Generator
|
|
****************************
|
|
|
|
The Gambit Scheme code generator can be accessed via the REPL command:
|
|
|
|
::
|
|
|
|
Main> :set cg gambit
|
|
|
|
Alternatively, you can set it via the ``IDRIS2_CG`` environment variable:
|
|
|
|
::
|
|
|
|
$ export IDRIS2_CG=gambit
|
|
|
|
To run Idris programs with this generator, you will need to install
|
|
`Gambit Scheme <https://gambitscheme.org>`_. Gambit Scheme is free software,
|
|
and available via most package managers.
|
|
|
|
You can compile an expression ``expr`` of type ``IO ()`` to an executable as
|
|
follows, at the REPL:
|
|
|
|
::
|
|
|
|
Main> :c execname expr
|
|
|
|
...where ``execname`` is the name of the executable file. This will generate
|
|
the following:
|
|
|
|
* An executable binary ``build/exec/execname`` of the program.
|
|
* A Gambit Scheme source file ``build/exec/execname.scm``, from which the
|
|
binary is generated.
|
|
|
|
You can also execute an expression directly:
|
|
|
|
::
|
|
|
|
Main> :exec expr
|
|
|
|
Again, ``expr`` must have type ``IO ()``. This will generate a temporary
|
|
Scheme file, and execute the Gambit interpreter on it.
|