Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keeping quotations as tuple members in Factor

Tags:

factor-lang

I want to keep a quotation as a member of a tuple in Factor. But when I try to execute 'call' on it I get the error 'cannot apply call to a run-time computed value'. Note that marking the functions as 'inline' does nothing.

Sample code:

USING: accessors kernel ;
IN: stackoverflow

TUPLE: quottuple quot ;
C: <quottuple> quottuple

: call-quot ( quottuple -- result )
    quot>> call ; inline

: main ( -- )
    [ 1 ] <quottuple>
    call-quot drop ;

MAIN: main
like image 495
Randy Voet Avatar asked Dec 03 '10 10:12

Randy Voet


1 Answers

The answer is the 'call(' word. That word requires you to specify the stack effect of the quotation, but as a result the quotation doesn't need to be known at compile time.

USING: accessors kernel ;
IN: stackoverflow

TUPLE: quottuple quot ;
C: <quottuple> quottuple

: call-quot ( quottuple -- result )
    quot>> call( -- result ) ;

: main ( -- )
    [ 1 ] <quottuple>
    call-quot drop ;

MAIN: main
like image 188
Randy Voet Avatar answered Oct 11 '22 10:10

Randy Voet