How to call a constructed quotation in Factor
Asked Answered
B

0

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.

Brainwork answered 30/1, 2013 at 7:21 Comment(1)
Might want to take your edit and turn it into an answer. Wouldn't want to steal your points.Moorwort

© 2022 - 2024 — McMap. All rights reserved.