Hi Kobi,

You need to ensure that the value passed in to 2cleave is constructed
at compile time. To do this, move the 'map' call inside the macro.

Also note that a macro's body must evaluate to a quotation, not a
value; and declaring a macro as 'inline' has no effect. However, I'm
puzzled as to why you're passing in the output of 'curry' as the assoc
key to 'at'. Perhaps you meant to do something else here.

Slava

On Mon, Nov 16, 2009 at 10:40 AM, Kobi Lurie <[email protected]> wrote:
>  Hey guys, if you may I would like to ask another question
> I get an error about 2cleave cannot be compiled from the following code.
> And I feel in any case I'm going the wrong way here.
> Is what I'm doing makes sense?
> please give pointers. Also I'm new to macros, not sure I use them correctly.
> The purpose of the code is to get values from a hashtable and put them
> into the tuple fields. (or 'f' if they couldn't be found)
>
> Many thanks, Kobi
>
> TUPLE: smtp-config server local-domain tls? smtp-read-timeout smtp-auth
> username password ;
>
> : value-slot-pairs ( -- seq )
>     {
>         {  [ "server" ]            [ >>server ] }
>         {  [ "local-domain" ]      [ >>local-domain ] }
>         {  [ "tls?" ]              [ >>tls? ] }
>         {  [ "smtp-read-timeout" ] [ >>smtp-read-timeout ] }
>         {  [ "smtp-auth" ]         [ >>smtp-auth ] }
>         {  [ "username" ]          [ >>username ] }
>         {  [ "password" ]          [ >>password ] }
>     } ; inline
>
> MACRO: (prepare-table) ( pair-seq -- )
>     first2 [ when* drop ] curry
>     [ swap at ] prepose compose ; inline
>
> : hash>slots ( tuple hash pair-seq -- tuple' )
>     [ dup ] 2dip
>     [ (prepare-table) ] map 2cleave ;
>
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Factor-talk mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to