Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Paul Rubin Newsgroups: comp.lang.forth Subject: Re: Implementing lisp in Forth. Chapter 4. Date: Sun, 04 Sep 2016 11:28:54 -0700 Organization: A noiseless patient Spider Lines: 41 Message-ID: <87fupfo6xl.fsf@jester.gateway.pace.com> References: <8737lkpr8n.fsf@jester.gateway.pace.com> <87twdznhhz.fsf@jester.gateway.pace.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="7bfc8f5b1c0c0e2e29d3a5c3abe51644"; logging-data="31189"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19IXmysxevHzSMV6b2T7/87" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:RpMLpsolQg3Ipq+U4G/hGvhq17o= sha1:quepcsQmwuct0G0phZ+DnBEEJ6U= Xref: csiph.com comp.lang.forth:50661 albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) writes: > The GC seems to be a difficult part. How can there be one if there > is no lisp yet to speak of? A c-library? Anton Ertl has already written one in Forth: http://www.complang.tuwien.ac.at/forth/garbage-collection.zip It supplies an ALLOC word that gives you a chunk of memory of you desired size. There is no corresponding FREE, since ALLOC notices if you're running low on memory, and performs a GC if you are. I'm suggesting that you use Anton's package and write Lisp-callable words like CONS as Forth words that use ALLOC, so the GC part is already done for you. > The whole point of Forth is that such a reader be modular and handled > by the Forth interpreter. That is the crux of this exercise. If the exercise is just to write a Lisp reader in Forth, then ok; but in terms of getting a Lisp working, the reader is just a component. >> instead oftreating "baz)))" as a Forth word? > I'll need a TOKEN2 with the second ?BLANK replaced by ?BLANK-OR-) > : ?BLANK-OR-) DUP &) = SWAP ?BLANK OR ; There are a few other characters like ' (quote) that you'll also want to treat specially. It's not terrible but I don't see much gain from this approach. > Or I may just require (+ 1 2 3 baz ) Noooo...... > You got me wrong. I don't want to write a Lisp. I want to demonstrate > that Forth can be used to write a Lisp. I'm rather liking the idea of a Forth with a Lisp extension. You could then use Forth directly to write the realtime or speed-intensive parts of a program and parts that need to address raw memory, and Lisp for higher-level parts, UI, etc.