2015-06-23 14:54 GMT+02:00 Barry Fishman <barry_fish...@acm.org>:

>
> On 2015-06-23 17:19:56 +0800, Nala Ginrut wrote:
> > On Tue, 2015-06-23 at 11:12 +0200, to...@tuxteam.de wrote:
> >> What does number/base do? Does it change the read syntax of numbers?
> >>
> >
> > I think it defines a function (number/base base) first, then use it as
> > argument of the outer function...
> >
> > http://docs.racket-lang.org/reference/define.html
> >
>
> How is this syntax macro style improve on a more direct and simple
> standard scheme implementation of:
>
> (define (number/base base)
>   (lambda (lst)
>     (let loop ((digits lst)
>                (accumulator 0))
>       (if (null? digits)
>           accumulator
>           (loop (cdr digits)
>                 (+ (car digits) (* accumulator base)))))))
>
>
I think it's the same improvement as between your version and the even more
"direct and simple" standard scheme implementation:

(define number/base
  (lambda (base)
    (lambda (lst)
       (let loop ((digits lst)
                      (accumulator 0))
          (if (null? digits)
             accumulator
             (loop (cdr digits)
                     (+ (car digits) (* accumulator base))))))))

(And using obscure names such as "car" and "cdr" in the code doesn't
enhance readability either)

This amalgam of 'match' and 'define-syntax's style '...', and
> 'destructuring-bind' syntax just seems to add complexity to a language
> whose prime benefit is the clarity of its explicitness and lack of
> syntax.
>

I agree that the presence of ellipsis in the pattern matcher is dubious. On
the other hand, since it's already there, it allows to make it clear to the
reader that a given argument is meant to be a list.

OTOH I see that it wasn't much of a problem for you to understand the code.

Best regards
M.

Reply via email to