8

I have a word which constructs a quotation which I want to be called. However, when I load the code I get Cannot apply “call” to a run-time computed value. If I use the walker and step thru the code it executes as expected. How are you supposed to call a constructed quotation?

: ba>struct ( array class -- struct array )
[ <struct> swap ] keep struct-slots
[
    [ type>> to-type ] keep  
    name>> setter-word 1quotation curry
    [ over ] dip  curry  call drop
] each
; 

EDITED: This does work

: ba>struct ( array class -- struct array )
    [ <struct> swap ] keep struct-slots
    [
        [ type>> to-type ] keep  
        name>> setter-word 1quotation curry
        [ over ] dip  curry  call( -- x ) drop
    ] each
    ; 

The problem stems from the runtime not knowing what the stack effect is of a constructed quote. In these cases, you must declare what the stack looks like to the quote for the call.

Matthew Lundberg
  • 42,009
  • 6
  • 90
  • 112
tgunr
  • 1,540
  • 17
  • 31
  • Might want to take your edit and turn it into an answer. Wouldn't want to steal your points. – Sled Mar 13 '20 at 15:19

0 Answers0