This is the mail archive of the cgen@sources.redhat.com mailing list for the CGEN project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Porting CGEN to other Scheme implementations


I'm interested in porting CGEN to MzScheme.  MzScheme has an active
development community, and (of particular interest to Red Hat) an
actively maintained Scheme-to-C compiler.  I'd like to talk about how
I'm thinking of approaching it, and see what folks think.

I'd like to convert CGEN to use standard R5RS scheme where possible,
and have a per-implementation file --- guile.scm or mzscheme.scm ---
that is loaded before anything else that can define or fix things as
necessary.

The only big issue here is CGEN's use of Guile keywords.  Standard
Scheme doesn't have keywords at all.  Common Lisp allows one to
customize the reader pretty heavily, and I assume that has been
imitated in some Scheme systems, but R5RS Scheme does not, and
MzScheme only allows you to replace the reader entirely.

The "R5RS wherever possible" approach suggests that CGEN simply stop
using Guile keywords, and use symbols whose names begin with :, or
something like that, instead.  Older Guiles used to recognize :foo as
a keyword object, but that was made optional and disabled by default,
since there is Scheme code out there that uses symbols whose names
start with : as symbols.

I've gotten this working for cgen-sid.scm, and it wasn't too bad.
It entailed:
- defining a 'cgen-keyword?' function
- replacing #:foo with either :foo or ':foo
- looking for cases where we check (symbol? foo) before we check
  (keyword? foo)

We'll need some way to produce a helpful warning when people read old
.cpu files with a new CGEN.


At the moment, to build SID files, for example, we invoke Guile like
this:

    guile -s cgen-sid.scm <cgen flags>

The '-s SCRIPT' terminates Guile's argument parsing and passes the
remaining arguments to the script itself.  I'd like to change the
cgen-FOO.scm scripts to expect to be invoked like this:

    guile -l ${cgensrc}/guile.scm -s cgen-sid.scm <cgen flags>

or

    mzscheme -f ${cgensrc}/mzscheme.scm -r cgen-sid.scm <cgen flags>

which have the effect you'd guess.  guile.scm and mzscheme.scm are new
files that would get loaded first, and could do whatever compatibility
trickery was needed.

Most of the stuff in fixup.scm, and some stuff from read.scm, would
move to the new guile.scm.

Thoughts?  Objections to the whole enterprise?  Doughnuts?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]