Joshua N Pritikin wrote: > I'm not sure if you're trying to elaborate on my proposal or you're > coming up with something completely different. Elaborate on how your proposal might work. Sorry if I misunderstood you -- consider my proposal something completely different then. > > 1. A micro-perl compiler is written in micro-perl. > > For the record, I never advocated writing a perl compiler in perl. I > envisioned a three step process: > > perl code generator (in perl) => C/C++ compiler => perl Hmm. You're going to write a perl program that when run generates C code that when compiled is a perl interpreter. That sounds a *lot* like a compiler to me... Unless you're thinking about something more like: print <<'EOF'; #include <stdio.h> main() { printf("hello world\n"); } EOF Maybe somewhere between the two extremes, but closer to the later? > I'm not sure whether perl can be implemented in perl. Even if it can, > why bother? Because it's a good way to get an implementation with clearly defined interfaces and simple structure without a lot of code. For example, I'd love to have the Perl 6 parser and resulting parse tree hackable in Perl without having to dive into C. IMHO the best way to achieve that is to implement the parser in Perl. If we have a Perl parser in Perl, then why wouldn't we slap a back-end on it and make it a Perl compiler? (Even if it's just a subset of Perl it would still be *really* useful.) I'd also like to never see another line of XS code -- I just want to put a couple declarations into my Perl code and then compile it to a loadable module. Something like: sub smaller { my($a, $b) = @_; extern "C" int strcmp(const char *, const char *); (strcmp($a, $b) <= 0) ? $a : $b; } There's nothing fancy going on there; a micro-perl compiler could handle it just fine. > > Micro-perl is an easily compiled > > subset of Perl 5: No eval, no dynamic symbol table stuff, no BEGIN/END, > > no overloading, no garbage collection, etc. > > So can it do anything?? Sure. It knows all about the internal representation of data and how to do primitive operations on the data. It's got namespaces and can figure out when to allocate data on the stack vs. the heap. It's got flow control and subroutines and I/O. It can box/unbox data lazily. It's a super-set of C, but a subset of Perl. Basically it has everything that can be compiled into C without depending on the Perl run-time (other than support stuff like regexps and I/O). > > This is a total change in direction from previous work done with Topaz. > > Yes, well, my proposal was actually in a very similar direction in > comparison with Topaz. How's that? - Ken