Hi, all--
Okay, so I am trying to understand how macros work in Factor. I wrote my
first macro last night, which looks like this:
MACRO: print-with-suffix ( str -- ) append print ;
Then I can define a word in terms of the macro:
: print-with-yeah ( str -- ) " yeah!" print-with-suffix ;
Hi Matt,
You don't need a macro to do what you're doing:
: print-with-suffix ( str -- ) append print ;
is correct as is. Macros are for expanding code at compile-time. In
the UI, do "macros" about and read the docs. Some good examples of
macros are in basis/generalizations and basis/combin
Matt,
Doug wrote a very detailed e-mail that explains everything; I'd just
like to add a couple of minor points.
If it wasn't for the compiler, then the following would be equivalent:
MACRO: foo ( x -- ) bar ;
: foo ( x -- ) bar call ;
What the compiler does, then, is if it encounters a call to
Doug Coleman wrote:
> You don't need a macro to do what you're doing:
>
> : print-with-suffix ( str -- ) append print ;
Oh, yeah ... I knew that, sort of. My example was derived from something
I was recently working with in Scheme, which really did need to be a
macro. I simplified it to try to
On Sun, Feb 15, 2009 at 6:13 PM, Matt Gushee wrote:
> BTW, I would still like to see a precise definition of "static stack
> effect."
This article explains the details,
http://docs.factorcode.org/content/article-inference.html
Slava
-
Hi Matt,
> BTW, I would still like to see a precise definition of "static stack
> effect."
Briefly, a word with a static stack effect has the same stack effect
every time it is run. For example, drop ( x -- ). This is in contrast
to words with a dynamic stack effect, such as call, whose stack eff