If we use

(define-syntax define/memoized
  (syntax-rules ()
    ((_ (name . args) . body)
     (define name (memoize (lambda args  body))))))

and body is bound to    ((displayln x) (displayln y) (displayz))
then

    (lambda args  body)

will become

    (lambda <something> ((displayln x) (displayln y) (displayz)))

And when this function is called you will get an error since

    ((displayln x) ...)

means apply the result of (displayln x) to (displayln y) (displayln x).

/Jens Axel




2016-03-13 19:32 GMT+01:00 Pedro Caldeira <pedro.calde...@bluewin.ch>:

> Sorry I've messed up my reply, here's the actual reply
>
> >Imagine (_ (foo x y z) (displayln x) (displayln y) (displayln z)) as the
> actual syntax. The .body will be bound to the sequence of three diaplaylns
> and this sequence will become the body of the lambda in the expansion.
> So in this case body will be bound to the list ((displayln x) (displayln
> y) (displayz)) right?
>
> So why do we use the '.' in the lambda declaration, couldn't we just write:
> (define-syntax define/memoized
>   (syntax-rules ()
>     ((_ (name . args) . body)
>      (define name (memoize (lambda args  body))))))
> In Scala the head and tail of a list can be matched in the following way:
> x :: xs with x being the head and xs the tail, is the dot notation similar
> in purpose? Is the expression (x . xs) in Racket used to match x with the
> head of the S-expression and xs with the rest of the S-expression?
>
> >(define-syntax define/memoized
> >  (syntax-rules ()
>
> >    ((_ (name arg ...) form ... expr)
> >     (define name (memoize (lambda (arg ...) form ... expr))))))
> I see thank you for the different format, the notation with the tree dots
> is more intuitive. As a side note in the racket reference:
> https://docs.racket-lang.org/reference/stx-patterns.html is the pattern
> with the three dots described by (pattern ...) or by (pattern ellipsis)?
>
> @Jens Alex
> Thank you for the clarification, I think it might confirm what I wrote
> above (I was replying while you answered)
>
> Again, thank you all for your time!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-- 
Jens Axel Søgaard

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to