[doc + headers tom@goto10.org**20071101201214] { addfile ./doc/.header.html hunk ./doc/.header.html 1 + + +
+This directory contains some disorganized documentation. For a more
+consistently structured introduction, have a look at the purrr and
+synth papers.
+
+ + hunk ./doc/ramblings.txt 15685 + +Entry: name spaces and objects +Date: Wed Oct 31 23:32:41 CET 2007 + +i'm trying to figure out how to make the name manging work well enough +to create static metaprogramming interface which supports generic +programming at the macro level. + + * write algorithms in macro form + * instantiate them statically as many times you need + + +what i'm really missing is higher level macros. with those, i can +build anything i want really.. + +so why is it impossible to have those? i probably need to give up on +forth syntax.. + +(let me finish my verbose buffer code before i try to answer..) + +ok. i don't know really. + +let's first try to get things like this out of the way: + +: bbf.tx-empty>z bbf.tx buffer.empty>z ; +: bbf.rx-empty>z bbf.rx buffer.empty>z ; +: bbf.rx-room>z bbf.rx buffer.room>z ; +: bbf.tx-room>z bbf.tx buffer.room>z ; + +: bbf.>tx bbf.tx buffer.write ; +: bbf.>rx bbf.rx buffer.write ; +: bbf.tx> bbf.tx buffer.read ; +: bbf.rx> bbf.rx buffer.read ; +: bbf.clear-tx bbf.tx buffer.clear ; +: bbf.clear-rx bbf.rx buffer.clear ; + +what i want is just + + ' bbf.tx- compile-buffer + ' bbf.tx- compile-buffer + +i can't even do variables since they are macros.. + + * yeah i need to be able to generate macros + * and fix name clashes within a compilation unit: both words and macros. + +maybe the trick is really to define 'compilation unit' properly? + +in my current approach, a macro can't pop up during expansion of code. + + +i need to get the philosophy right: + + * a flat namespace is nice for an application: everything is + concrete. we're "among freinds" and last names are not necessary. + + * it sucks for writing library code + +the solution in mzscheme that works for me is functions + +modules. local module namespace can be used for small specialized +utility words. i'd like to have something like that in forth. + +the problem is: i'm taking a really static stance in which macros play +a central role, not functions. this works as long as macros are +sufficiently powerful, which means higher order macros. + +now, let's pull the problems i'm having apart: + + +i wrote some buffer code, which is just macros. to instantiate a +buffer one doesn't simply do "bla create-buffer" or something, but it +is necessary to specialize a lot of functions manually. that's +completely unacceptable. + + +Entry: higher order macros +Date: Thu Nov 1 01:06:36 CET 2007 + +In order to solve some particular template problems, i'd like to have +higher order macros. this amounts to instead of splitting up a source +file as: + + MACROS -> PROCEDURES + +splitting it up as + + ... -> MACROS^2 -> MACROS -> PROCEDURES + +of course, there should be no limit to the tower. + + +The real problem is: i have no sane syntax space left! In macros i +can do this: + + macro : make-a-123 + ' a-123 *: 123 exit ; + +which is already pretty ugly because of quoting issues. But what am i +going to invent to make higher level expansion work? + +One thing is sure: taking out the reflection (making macros +side-effect free) killed the possibility of generating names at +compile time, EXCEPT for function labels. But those are really just +data: it's a hack that doesn't really count. + + So I have a GOOD THING: independent declaration instead of + sequential variable mutation for creating new macro names, that + causes a BAD THING: limited reflection due to improper phasing. + +Actually, I already knew that, but i'm starting to feel it now: +artifical limits are no good. Even if they serve a higher goal.. Maybe +that makes them not artificial? + +The limit i created is actually there for a reason: to use partial +evaluation to make it possible to perform compile time operations +without the need for an explicit meta language: without the need for +quotation like `(+ ,a ,b) or it's beefed up syntax-case / syntax-rules +variant. + +(funny how the only 'meta' part of the language is the macro stack: it +punches holes in reality somehow ;) + +So let's pat myself on the back: + + * the current macro / forth thing is GOOD. it is easy to use, easy + to understand, and avoids most quotation issues that arise in + practice by relying on partial evaluation. it gets pretty far + without the need for an explicit metalanguage. + + * it's NOT GOOD ENOUGH because it's the top level: it can't be + metaprogrammed itself! + + +The metaprogramming operations i'm looking for are those that create +new macro NAMES. Creating new macro BODIES should not be so terribly +hard: it is in fact what should be used for the quotation based +language. + +So the core of the business should be the question why this works in +scheme: + +(define-syntax make-macro + (syntax-rules () + ((_ name body) + (define-syntax name + (syntax-rules () + ((_) body)))))) + +box> (make-macro bla (+ 1 2)) +box> (bla) +3 hunk ./doc/technocore.txt 1 -* macros and assembler -* document error messages - rmfile ./doc/technocore.txt hunk ./host/compiler.ss 207 - (([qw method] [qw class] prefix) + (([qw method] [qw class] [qw dash] prefix) hunk ./host/compiler.ss 209 - (format "~a.~a" class method))])) + (format "~a~a~a" class dash method))])) hunk ./host/compiler.ss 277 - (pc prefix compile) ;; method object -- + (pc ' |.| prefix compile) ;; method object -- + + hunk ./pic18/frame.f 1 -\ Framed Receiver/Transmitter - +\ Bit Banged Framed Byte Receiver/Transmitter hunk ./pic18/frame.f 8 +\ NOTE: i'd like to automate this specialization a bit more, but i +\ don't know how to do it yet. It requires higher order macros that i +\ don't know yet how to implement. So until that time, this code is +\ specialized for ONLY ONE rx/tx in the global namespace, and it's NOT +\ PREFIXED! I decided to prefix the async serial words instead, so at +\ least they don't clash. + hunk ./pic18/frame.f 17 -2variable tx-r/w -2variable rx-r/w + hunk ./pic18/frame.f 23 +: rx-ready? rx-empty>z z? not ; hunk ./pic18/frame.f 28 +2variable tx-r/w +2variable rx-r/w + hunk ./pic18/frame.f 32 +: rx-empty>z rx buffer.empty>z ; hunk ./prj/hub/slave.f 74 - rx> tx> + rx> >tx hunk ./prj/hub/slave.f 85 - }