Cat 0.14 Release
Christopher Diggins — 2007-05-22 08:08:33
William Tanksley, Jr — 2007-05-22 14:00:26
Christopher Diggins <
cdiggins@...> wrote:
> Major New Features:
> - There is now a macro rewriting system (
> http://code.google.com/p/cat-language/wiki/Macros ) called MetaCat
> based on Manfred von Thun's paper "A Rewriting System for Joy". This
> system can be used for optimization and to express the semantics of
> the rest of the Cat language.
Impressive.
Can macros be typechecked? Can guards be set to conditionally allow or
disallow the expansion of macros? Are macros specifically checked for
identity, is it assumed, or can macros cause wildly different results?
Can a macro cause type-conformant code to be non-conformant?
I see that it's implementation-dependant whether a macro is allowed to
reduce code. I think that makes sense, but I think that should
probably be formalized a bit, and control over whether a macro reduces
code that it matches be given over to the programmer (possibly with a
simple rule to prevent huge delays). But that's a HUGE project,
obviously.
> Christopher Diggins
-Billy
Christopher Diggins — 2007-05-22 21:21:49
On 5/22/07, William Tanksley, Jr <
wtanksleyjr@...> wrote:
> Christopher Diggins <cdiggins@...> wrote:
> > Major New Features:
> > - There is now a macro rewriting system (
> > http://code.google.com/p/cat-language/wiki/Macros ) called MetaCat
> > based on Manfred von Thun's paper "A Rewriting System for Joy". This
> > system can be used for optimization and to express the semantics of
> > the rest of the Cat language.
>
> Impressive.
Thank you. :-)
> Can macros be typechecked?
How were you thinking? I plan to add the feature later on that value
variables can have type restrictions, like:
macro { $a:int $a:int add } => { $a $a add_int }
For now there isn't such features.
> Can guards be set to conditionally allow or
> disallow the expansion of macros?
No, but that would be a good idea.
> Are macros specifically checked for
> identity, is it assumed, or can macros cause wildly different results?
The macros are assumed to be compatible with the langauge semantics.
If MetaCat matures later on then it could be concievable that MetaCat
actually defines the operational semantics of the language, which
would be trluy mind-blowing, but not outsiode of the realm of
possibility. Alan Kay I believe is working on something similar.
> Can a macro cause type-conformant code to be non-conformant?
Yep.
> I see that it's implementation-dependant whether a macro is allowed to
> reduce code. I think that makes sense, but I think that should
> probably be formalized a bit,
I agree.
> and control over whether a macro reduces
> code that it matches be given over to the programmer (possibly with a
> simple rule to prevent huge delays). But that's a HUGE project,
> obviously.
It might not be too bad, if I add namespaces, macro prioritization,
and macro expansion directives. I can imagine a simple import
directive inside of a namespace, that brings macro rules in to bear on
a specific scope (e.g. curly brace blocks), and other directives that
allow control.
The big challenge is to do such things elegantly. The notion of
namespaces is something that I have been playing with for a while and
have somewhat prepared in the code-base.
Thanks for the feeback.
Cheers,
Christopher
William Tanksley, Jr — 2007-05-22 21:50:19
Christopher Diggins <
cdiggins@...> wrote:
> William Tanksley, Jr <wtanksleyjr@...> wrote:
> > Impressive.
> Thank you. :-)
Talk is cheap -- code (and good specifications) are much harder.
> > Can macros be typechecked?
> How were you thinking? I plan to add the feature later on that value
> variables can have type restrictions, like:
> macro { $a:int $a:int add } => { $a $a add_int }
That's essentially what I was thinking, yes. I guess I should call
those type guards rather than type checks, since they can't make the
macro valid or invalid; rather, they force the macro to only apply to
text if the types involved match.
> For now there isn't such features.
That's just fine.
> > Are macros specifically checked for
> > identity, is it assumed, or can macros cause wildly different results?
> The macros are assumed to be compatible with the langauge semantics.
Assumptions are just fine, also.
> If MetaCat matures later on then it could be concievable that MetaCat
> actually defines the operational semantics of the language, which
> would be trluy mind-blowing, but not outsiode of the realm of
> possibility. Alan Kay I believe is working on something similar.
A very interesting point! Actually, this did pop into my mind, since
your macro notation reminded me of Kerby's combinator notation.
> > Can a macro cause type-conformant code to be non-conformant?
> Yep.
Is code typechecked both before and after substitution?
> > I see that it's implementation-dependant whether a macro is allowed to
> > reduce code. I think that makes sense, but I think that should
> > probably be formalized a bit,
> I agree.
...but saying "should probably be formalized" is a long way from doing
the work to formalize them. :-)
> > and control over whether a macro reduces
> > code that it matches be given over to the programmer (possibly with a
> > simple rule to prevent huge delays). But that's a HUGE project,
> > obviously.
> It might not be too bad, if I add namespaces, macro prioritization,
> and macro expansion directives. I can imagine a simple import
> directive inside of a namespace, that brings macro rules in to bear on
> a specific scope (e.g. curly brace blocks), and other directives that
> allow control.
True. I was thinking of a system which could express arbitrary
identity transformations, and coordinate among them so that the
language's entire optimizer could be expressed in its metalanguage.
THAT is a big challenge.
> The big challenge is to do such things elegantly.
Yes, elegance is difficult.
> The notion of
> namespaces is something that I have been playing with for a while and
> have somewhat prepared in the code-base.
Cool.
> Thanks for the feeback.
Thank you for the solid work!
> Christopher
-Billy