2015-08-30 14:30 GMT+02:00 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>:
This is a bit of a crank idea, but here goes.

Today I wasted some time trying to find the bug in the following piece
of code:

    (define (syntax-car syntax)
      (syntax-case syntax () ((car . cdr) #'car)))

Better error reporting in macro-expansion errors might have made it less
painful, but maybe we can solve the problem itself.

How about making 'foo turn into something like (__quote__ foo), and
similar for `foo, #'foo, etc.?  Where __quote__ is just a synonym to
quote, and the original works too.  Ideal would be a symbol that's not
as noisy (in debug output) but still highly improbable to appear in user
code and be accidentally shadowed.


You mean that #'x is synonymous to (syntax x), and that's where the problem stems from?
 
Maybe it would not be standards-compliant in the strict sense, but I
believe it would be an improvement.

Am I missing any obvious downsides?  Or any subtle ones?


I think that every lisper should know that 'x is synonymous to (quote x), and in some contexts it might be desirable to bind a new meaning to the "quote" form (and this is already done by some libraries, notably in the (ice-9 match) module).

As to "syntax", the use of #'x is much rarer, and the idea that #'x is (syntax x) is indeed a bit controversial. But this regards the whole syntax-case macro system, and I think that it would be more valuable to think how to fix its flaws, rather than change the very fundamentals of the language.


Best regards,
M.