Marc Nieper-Wißkirchen
2018-11-15 16:55:15 UTC
I would like to alias an identifier in Guile. By this, I mean the
following: Given a bound identifier `x', I want to lexically introduce
another identifier `y' with the same binding as `x' so that `x' and `y'
become `free-identifier=?'.
The following is one use case: I have written a macro `custom-quasiquote`,
which has a similar syntax and does similar things as `quasiquote' does.
Because I would like to use the special reader syntax for `quasiquote', I
would do:
(letrec-syntax ((quasiquote <custom-quasiquote-transformer>))
<body>)
In the <body>, whenever I write ``<template>', my
<custom-quasiquote-transformer> is being applied to <template>.
There may be parts in the <body> where I would like to use Scheme's
quasiquotation. One try is to surround these parts with:
(let-syntax ((quasiquote (identifier-syntax scheme-quasiquote)))
<expression>)
Here, `scheme-quasiquote' is bound to `quasiquote' as exported by
`(guile)'. However, this solution is not correct as the `quasiquote' local
to <expression> is not `free-identifier=?' to `scheme-quasiquote'. Thus
quasiquotations containing quasiquotes (that should become auxiliary
syntax) won't work right.
What I really need is to make the inner `quasiquote' a true alias of
`scheme-quasiquote' (or rather to restore the binding of `quasiquote' in
<expression> to what the binding outside the outer `letrec-syntax' was).
Chez Scheme has `alias' for this purpose:
https://cisco.github.io/ChezScheme/csug9.5/syntax.html#./syntax:h10.
What can I do in Scheme? If this is currently impossible, please consider
this post as a feature request for `alias' or a similar binding construct.
:-)
-- Marc
following: Given a bound identifier `x', I want to lexically introduce
another identifier `y' with the same binding as `x' so that `x' and `y'
become `free-identifier=?'.
The following is one use case: I have written a macro `custom-quasiquote`,
which has a similar syntax and does similar things as `quasiquote' does.
Because I would like to use the special reader syntax for `quasiquote', I
would do:
(letrec-syntax ((quasiquote <custom-quasiquote-transformer>))
<body>)
In the <body>, whenever I write ``<template>', my
<custom-quasiquote-transformer> is being applied to <template>.
There may be parts in the <body> where I would like to use Scheme's
quasiquotation. One try is to surround these parts with:
(let-syntax ((quasiquote (identifier-syntax scheme-quasiquote)))
<expression>)
Here, `scheme-quasiquote' is bound to `quasiquote' as exported by
`(guile)'. However, this solution is not correct as the `quasiquote' local
to <expression> is not `free-identifier=?' to `scheme-quasiquote'. Thus
quasiquotations containing quasiquotes (that should become auxiliary
syntax) won't work right.
What I really need is to make the inner `quasiquote' a true alias of
`scheme-quasiquote' (or rather to restore the binding of `quasiquote' in
<expression> to what the binding outside the outer `letrec-syntax' was).
Chez Scheme has `alias' for this purpose:
https://cisco.github.io/ChezScheme/csug9.5/syntax.html#./syntax:h10.
What can I do in Scheme? If this is currently impossible, please consider
this post as a feature request for `alias' or a similar binding construct.
:-)
-- Marc