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

Re: XML as a transition to s-expr



Michael Vanier writes
> > From: Paul Prescod <paul@prescod.net>
> > 
> > I'm going to risk flamage and say that Scheme (not MZScheme or BobScheme
> > but R5RS Scheme) does have usability problems. I came to that conclusion
> > watching the DSSSL experiment. It looks to me as if you are going to
> > replicate the experiment with BRL.
> > 
> >  * the parens are poor for error reporting. You could imagine a Lisp
> > that would report syntax errors much more reliably:
> 
> I agree.  In mzscheme you can use [] or {} as substitutes for () that have
> to match their counterparts.  This improves the situation considerably.
> But I wish there was a more comprehensive way to (optionally) specify end
> markers in lisp (e.g. ".if" to end if).

In many Scheme impls including MzScheme, you could use
the nicely clunky #|fi|# for this purpose.
Unfortunately, #|...|# isn't in R*RS (yet?).  It
is standard CL.  

Or did you want something that errors on
mismatch, even though it is optional?  

(Paul Prescod)
> > As it is, Scheme errors can be reported miles away from where you
> > actually forgot a paren.

This may be the one pitfall of the code-as-data concept
that we all (for some values of "we" and "all") know &
love.  The reason we put up with it is because
code-as-data teams up well with parens to give us
versatile macros, as Paul (Graham) has been saying all
along.  

But the error-feedback problem may be addressed by the
machinery implied by the more involved "low-level"
macros.  These have been on the horizon for a while,
and are already available in impls such as MzScheme,
Chez and Sergei Egorov's Sxema.  (I hope implementors
and standardizers will join with their more
intimate expertise on this matter.) 

Code is here not quite data, but...  code and
data can be easily coerced to each other as needed.
Code is an object one of whose fields is the datum
(Scheme s-expression) representing it to human eyes,
but it can also contain other fields such as
line-number and file-name info.  The coercing function
calls are

(syntax-object->datum syntax-object)

  which rips out the line-number info, among others,
  returning the bare s-expression; and

(datum->syntax-object reference-syntax-object datum)

  which creates a syntax-object from datum, using 
  reference-syntax-object to fill up the fields.

You absolutely don't lose macros.  You can write
conventional or classical Lisp macros with this system
as you've always done, with a couple of to-and-fro
coercions thrown in at non-surprising points in the
definition.  And if you don't like that, you can define
a classical-looking defmacro as a macro (or load a
library) and pretend thereafter that you never heard
nothing about no weird coercions.  But you will retain
the advantage of having error locations faithfully
reported in your error messages, whether your code used
your defmacro, the primitive syntax extender, or was
macro-free.  

Users will still have to use s-expressions to write
code, but they don't have to settle for a poor error
reporter also.  Even in the shorter run, getting proper
error feedback should be more effective than
signing on for mandatory visual props forever.  

> >  * the Lisp community has an attitude, totally at odds with, let's say
> > the Perl community, that you can get around this problem with the "right
> > tools" that will do brace-matching for you. Python people have this
> > attitude to some extent also, but I'll note that most editors (even
> > Windows notepad) come out of the box configured to work okay with
> > Python.
> 
> I don't see this as an issue.  Almost any decent editor will do
> paren-matching.  Most people do find )))))))) at the end of functions
> pretty distracting, but you learn to tune it out.
> 
> >  * the parens do not sufficiently denote "parts of speech". 

Editors, even vi, will match parens.  But the danger
remains that they may match the wrong paren.  Allowing
for code-is-(not-just)-data should enable any Scheme
impl -- even the barer boned ones -- the wherewithal to
give some of the same kind of error feedback
currently provided by dedicated IDEs like DrScheme.

--d