chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] [MEGA-PATCH] Modularise the compiler!


From: Peter Bex
Subject: [Chicken-hackers] [MEGA-PATCH] Modularise the compiler!
Date: Sun, 17 Aug 2014 22:36:28 +0200
User-agent: Mutt/1.4.2.3i

Hello all,

This has been discussed here before: it would be great if the
compiler itself would be modularised, for various reasons:

- The private namespace hack gets in the way with symbol printing,
   as pointed out in #1077.
- Because it's not a proper module system and the "hide" list is manually
   maintained, the private namespace hack won't prevent all identifiers
   from leaking out.  As a silly example, +logged-debugging-modes+ will
   be visible in macros running inside the compiler, but not in the
   interpreter.  There are several other names that are missing from
   the list, and as I found out while modularising there are various
   names in the list which don't exist (anymore).
- Without a proper module system, the compiler is just a huge pile
   of globals that get set all around the place, and there is no
   layering at all, which makes it hard to grok the compiler's
   internal structure.  There are also some cyclic dependencies in
   there, as I found out.
- Because everything is just a global, there is no checking against
   typos or safety net against removing identifiers in only a few cases.
   I found out during this conversion that the no-parentheses-synonyms
   option for the compiler has probably been broken since its introduction
   in CHICKEN 4.1.0.
- There is no official API for compiler internals, leading to prolific
   hackery in some eggs, accessing compiler internals which were never
   meant to be accessed.  By using proper modules and documenting them,
   eventually this should make life easier for egg authors who wish to
   extend the compiler, too.

I realise that the attached patches are huge, and there are a LOT of
them.  However, I did my very best to keep the patches sort of
self-contained and for the first time ever I made plenty of use
of the git "rebase" feature in order to change stuff I missed along
the way in the historical revision where it should've been changed.

Most of the earlier commits are pretty mechanical anyway: just wrap
the file in a (module ...) form and watch the fallout, then add every
identifier that's used elsewhere to the export list.  Later commits
get trickier, as cyclic dependencies had to be resolved.

I hope the commit messages are descriptive enough, I tried to explain
everything I did in the patch in English, so that you don't have to
dig through the code too much to understand what's happening.

There's some remaining issues with this set of patches:

Various eggs are still using ##compiler#-prefixed identifiers.  Some
of them are pretty important eggs, and if these patches are committed
as-is, it will break the world.  Here's the list of eggs that I've
found:

- bind (and also easyffi)
- foreigners
- numbers
- peep
- crunch
- s48-modules

Some of them should be easy to fix, others would be very difficult.
I was hoping for some discussion on how to properly do this before
applying these patches.  Of course, feedback on the patches themselves
would be much appreciated too.  I intend to tag a new dev snapshot after
this change has gone in, so that we can add compile-time version checks
to these eggs where needed, so they can use the correct internal "API".

I didn't really change too much, though in some cases I tried to spec
out a bit of a proper "API", in the hopes that after basic modularisation
of the compiler we can start looking at it more seriously.  That's also
the reason I chose not to compile or install the import files: right now
they're purely generated and used by the compiler itself, for its own
bootstrapping.

If y'all prefer, I could push my branch to call-cc, if that makes it
easier to work on this.  I realise that sending 19 patches back and
forth over the mailing list will be very painful :)

Cheers,
Peter
-- 
http://www.more-magic.net

Attachment: 0001-compiler-modules-Add-normal-lookup-fallback-to-priva.patch
Description: Text document

Attachment: 0002-compiler-modules-Convert-batch-driver-to-a-module.patch
Description: Text document

Attachment: 0003-compiler-modules-Convert-lfa2-to-a-module.patch
Description: Text document

Attachment: 0004-compiler-modules-Convert-compiler-syntax-to-a-module.patch
Description: Text document

Attachment: 0005-compiler-modules-Convert-optimizer-to-a-module.patch
Description: Text document

Attachment: 0006-compiler-modules-Convert-c-platform-to-a-module.patch
Description: Text document

Attachment: 0007-compiler-modules-Convert-c-backend-to-a-module.patch
Description: Text document

Attachment: 0008-compiler-modules-Convert-scrutinizer-to-a-module.patch
Description: Text document

Attachment: 0009-compiler-modules-Convert-support-to-a-module.patch
Description: Text document

Attachment: 0010-compiler-modules-Simplify-compiler-module-import-for.patch
Description: Text document

Attachment: 0011-compiler-modules-Convert-compiler-to-a-module.patch
Description: Text document

Attachment: 0012-compiler-modules-Make-compiler-arguments-and-source-.patch
Description: Text document

Attachment: 0013-compiler-modules-Fix-no-parentheses-synonyms-flag-to.patch
Description: Text document

Attachment: 0014-compiler-modules-Move-all-profiling-support-code-to-.patch
Description: Text document

Attachment: 0015-compiler-modules-Reduce-coupling-between-components-.patch
Description: Text document

Attachment: 0016-compiler-modules-Move-foreign-callback-code-from-com.patch
Description: Text document

Attachment: 0017-compiler-modules-Make-bindings-non-global.patch
Description: Text document

Attachment: 0018-compiler-modules-Move-the-remaining-globals-unsafe-a.patch
Description: Text document

Attachment: 0019-compiler-modules-Finalize-modularisation-of-compiler.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]