On Tue 23 Aug 2011 01:17, Panicz Maciej Godek <[email protected]> writes:
> (array-set! a (* (array-ref a i j) 2) i j))
> seems to be unnecessarily prolix, for in C, language designed
> specifically to access arrays,
> the same operation could be written as
> a[i][j] *= 2;
With the appropriate macrology, it could look different:
(with-array-cells ((x (array-ref a i j)))
(set! x (* x 2)))
Seems OK to me. There are other possibilities. The macro:
(define-syntax with-array-cells
(syntax-rules (array-ref)
((_ ((sym (array-ref a idx ...)) ...) body body* ...)
(let-syntax ((sym (identifier-syntax
(var (array-ref a idx ...))
((set! var val) (array-set! a val idx ...))))
...)
body body* ...))))
Regards,
Andy
--
http://wingolog.org/