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

Re: define-reader-ctor is merely an implementation hint

This page is part of the web mail archives of SRFI 10 from before July 7th, 2015. The new archives for SRFI 10 contain all messages, not just those from before July 7th, 2015.



> > The only way to supply contructor functions in SRFI-10 is by doing
> > (define-reader-ctor <symbol> <proc>).
> 
> No. The only requirement SRFI-10 mandates is that "There must be a way
> to declare an association between a symbolic tag and the corresponding
> constructor-procedure." SRFI-10 goes on to _suggest_ that an
> implementation may want to implement a define-reader-ctor function for
> that purpose. SRFI-10 does not say that define-reader-ctor is the
> required method to build tag-constructor associations, let alone that
> it is the only method (see also below).

There is another alternative for defining the constructors within the
source code.  You could simply use the #,(...) form itself to perform
a definition while the program is being read.  For example you could:

'#,(define-reader-ctor 'box list)
'#,(define-reader-ctor 'f32 f32vector)

(define x '(things #,(box 123) #,(f32 1.0 2.0 3.0)))

Note that this assumes that define-reader-ctor is itself declared
as a reader constructor.

This doesn't solve the problem of specifying to the compiler any
non-standard procedures that are to be passed to define-reader-ctor,
but at least it will work when the constructors can be expressed in
standard Scheme.

I don't actually like this approach, but I mention it for the record.

Marc