Doug and John, thank you for the thorough explanation! 19.01.2018, 00:31, "John Benediktsson" :See this macro: MACRO: add ( n -- quot ) [ \ + ] [ ] replicate-as ; It's "stack effect" depends on the input. IN: scratchpad [ 1 add ] infer . ( x x -- x ) IN: scratchpad [ 2 add ] infer .
See this macro:
MACRO: add ( n -- quot )
[ \ + ] [ ] replicate-as ;
It's "stack effect" depends on the input.
IN: scratchpad [ 1 add ] infer .
( x x -- x )
IN: scratchpad [ 2 add ] infer .
( x x x -- x )
So you really can't do much more than say this macro produces some
quo
Oops.
MACRO: printf ( string -- quot: ( ..a string -- ..b ) )
MACRO: sprintf ( string -- quot: ( ..a string -- ..b string ) )
On Thu, Jan 18, 2018 at 3:02 PM John Benediktsson wrote:
> MACRO: always produces a quot.
>
> But when it's "called" it's whatever the stack effect of that produced
>
MACRO: always produces a quot.
But when it's "called" it's whatever the stack effect of that produced quot
is when it's expanded into the calling site.
On Thu, Jan 18, 2018 at 12:36 PM, Alexander Ilin wrote:
> O-kay... Let me try to ask my question again...
>
> I've read the blog post that y
We don't really have a solution for this right now.
Your stack effects wouldn't match with the convention we have right now of
just saying it outputs a ``quot``. I think we need to fix the stack checker
to be more exact before we change the code here.
This looks more correct but goes against conv
Can I simply change the stack effects for the purposes of documenting them like this?```MACRO: printf ( ... string -- )MACRO: sprintf ( ... string -- result )``` 18.01.2018, 23:44, "Doug Coleman" :Stack effects on macros are not checked. We have the convention of lying that the stack effect is ( i
Stack effects on macros are not checked. We have the convention of lying
that the stack effect is ( input -- quot ) but even that is wrong, as the
macro is called immediately so you don't get a quot on the stack. The quot
could have a stack effect of its own but it's variable arity, as you are
seei
O-kay... Let me try to ask my question again... I've read the blog post that you linked to. In there I found the following declaration:`MACRO: printf ( format-string -- )` This means that the macro takes one argument and removes it from the stack, doesn't put anything back. But in the actual source
Both of those are macros (basically special words that produce a
quotation), so when "called" they are first macro-expanded into a quotation
and then that quotation is called, with whatever stack effect it has.
IN: scratchpad 1 2 3 "%s %s %s" printf
1 2 3
IN: scratchpad [ "%s %s %s" printf ] infe