Re: [stack] possibilities for macros in a typed language
John Nowak <[email protected]>
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
Taking this a step further... Let's start with Kitten (Cat minus locals). Now let's also remove recursive definitions. In such a language, any definition is equivalent to its finite expansion. In other words, for every place the function 'f' is used, replacing 'f' with its definition will not alter the meaning of the program. If we do this, writing a program would consist of writing a series of rewrite rules. For example, if we do 'sqr = dup *', then every time 'sqr' is encountered, we can replace it with 'dup *'. (If the implementation actually does this or decides to call 'sqr' instead isn't interesting; the results are equivalent.) But why stop there? What if we allow rewrite rules along the lines of MetaCat as normal definitions? Even though we can't define 'm = dup i', we could define '$a m = $a $a i'. Optimizations like 'swap swap = ' could sit aside normal definitions. I feel like I'm probably reinventing something here. Are there any existing languages that work like this? - John