Ed Watkeys on 23 Aug 2007 13:18:57 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[philly-lambda] Re: Do you keep wishing for the patterns from other languages?




On Aug 22, 9:43 pm, "Kyle R. Burton" <kyle.bur...@gmail.com> wrote:
 (define-test (test-for-over-map)
>   (let ((res (list)))
>     (for each (key value) in-map
>          (aprog1
>           (java.util.HashMap.)
>           (.put it "foo" "bar")
>           (.put it "qux" "baz"))
>          (set! res (cons key res)))
>     (assert-equal res '("foo" "qux"))))

Kyle,

Why not just use LET?

(let ((it (java.util.HashMap.)))
  (.put it "foo" "bar")
  (.put it "qux" "baz")
  it)

In your example, you're not using the result of the APROG1 expression.

I really wished that I had anaphoric IF (AIF) where, log APROG1, you
can do stuff like this, IIRC:

(aif (assoc people 'kyle) (cdr it) #f)

But then I realized the COND lets me do assentially the same thing:

(cond ((assoc people 'kyle) =>
        (lambda (it) (cdr it)))
      (else
        #f))

As for the main point of your message: Yes, absolutely! I've come to
see Javascript as the nicest language with C-like syntax, because I
can use closures and first-class anonymous functions everywhere.
Writing Ajax apps almost requires that you think in terms of CPS
(continuation passing style).


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Philly Lambda" group.
To unsubscribe from this group, send email to philly-lambda-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/philly-lambda?hl=en
-~----------~----~----~----~------~----~------~--~---