On 12/09/2011 03:03 AM, Bruce & Breeanna Rennie wrote:
> Gentlemen and Ladies,
>
> I am looking at translating some scheme code to Unicon. However, there
> are a number of places where lambda expressions are used in the code. An
> example is the following code snippet
>
> #(define map-eval
> #  (lambda (operand-tree env context applicative)
> #    (if (not (kernel-list? operand-tree))
> #        (error-pass
> #          (make-error-descriptor
> #            (list "Operand tree not a list, passed to "
> #                  (describe-object applicative)))
> #          context)
> #        (simple-map
> #::
> #          (lambda (operand) (eval operand env context))
> #;;
> #          operand-tree))))
> #
>
> The specific segment is marked between the #:: rows.
>
> What suggestions are there to convert this to idiomatic Unicon code.
> Including using co-expressions etc.

Hi Bruce,

Co-expressions are almost natural lambda expressions.  All local variables in
the surrounding context are available, initialized to the values they
have at co-expression creation.  There's a little footwork involved
in passing the free variables down, but here's an example.  (I don't
know enough scheme to attempt to translate the above code, so don't
assume this matches what you need!)
-----------------------------------------------------
procedure applyTests(tree, env, context)
     c := create repeat {
               operand := (result@&source)[1]  # allows function-style calls
               result := operand(env, context) # in case result is needed
               }
     @c # advances evaluation CE to 'synchronization point', so next
         #   value passed in gets assigned to operand.
     every c(simpleMap(tree))   # here, result is ignored
end
-----------------------------------------------------

-Steve
-- 
Steve Wampler -- [email protected]
The gods that smiled on your birth are now laughing out loud.

------------------------------------------------------------------------------
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of 
discussion for anyone considering optimizing the pricing and packaging model 
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
_______________________________________________
Unicon-group mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/unicon-group

Reply via email to