Paste: hash>tuple Doesn't compile

Author: randy
Mode: factor
Date: Sun, 20 Dec 2009 15:14:00
Plain Text |
CONSTANT: value-slot-pairs 
    { 
        {  [ "server" ]            [ >>server ] }
        {  [ "local-domain" ]      [ >>local-domain ] }
        {  [ "port" ]              [ >>port ] }
        {  [ "tls?" ]              [ >>tls? ] }
        {  [ "smtp-read-timeout" ] [ >>smtp-read-timeout ] }
        {  [ "smtp-auth" ]         [ >>smtp-auth ] }
        {  [ "username" ]          [ >>username ] }
        {  [ "password" ]          [ >>password ] }
    } 
   
: ([item>][>field]) ( tuple hash quot-pair -- quot1 quot2 )
     swapd first2 
    [ swap ] prepose [ [ swap at ] compose ] dip bi-curry* ;

    
: hash-item>field ( tuple hash pair -- tuple' )    
    [ ([item>][>field]) dip when* ] with-compilation-unit ; ! cannot be compiled - how to solve?

Annotation: fixed

Author: blei
Mode: factor
Date: Sun, 20 Dec 2009 15:39:50
Plain Text |
:: ([item>][>field]) ( tuple hash quot-pair -- quot1 quot2 )
    quot-pair first2 :> ( key setter )
    key [ hash at ] compose
    setter [ tuple drop ] compose ;

: hash-item>field ( tuple hash pair -- tuple )
    [ dup ] 2dip ([item>][>field])
    [ (( -- obj )) call-effect ] dip
    '[ _ (( obj -- )) call-effect ] when* ;

New Annotation

Summary:
Author:
Mode:
Body: