guile-user
[Top][All Lists]
Advanced

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

Re: Reader syntax for accessing arrays


From: Panicz Maciej Godek
Subject: Re: Reader syntax for accessing arrays
Date: Fri, 26 Aug 2011 23:02:31 +0200

Howdie,

I would agree that specifying a rigid behavior for [] and {} brackets
is pretty far away from the minimalistic spirit of scheme. However,
section 7.1.1 of R5RS specification states, that characters [, ], {, }
and | are "reserved for further extension of the language".
(R6RS, on the other hand, makes a step backward, and indeed
specifies a trivial rigid behavior for []).

I eventually went without making a closure, and defined the
following syntax:

(define-syntax [
  (syntax-rules (])
    (([ v i ])
     (vector-ref v i))))

It has three disadvantages. Firstly, it still needs the additional
surrounding parentheses, secondly it requires spaces between
the adjacent symbols, and thirdly it is not R5RS compliant, due
to the reason stated above (and hence it doesn't work with
various scheme implementations).

I remember that I once used the infix module written by Daniel
Skarda, but it used the quite non-portable read-hash-extend and
I guess it is no longer shipped with guile.

I believe that there must be a way to utilize the square and
curly brackets that would suit the scheme philosophy. Perhaps
the bigloo's read mechanism is close to that way, as it is
conceptually simple, makes scheme more self-documentable
and allows it to remain compatible with the behavior of []
in R6RS, while enabling the programmer to specify new behavior
for it.

Best regards,
Maciek



reply via email to

[Prev in Thread] Current Thread [Next in Thread]