[Top][All Lists]

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

Aliasing an identifier

From: Marc Nieper-Wißkirchen
Subject: Aliasing an identifier
Date: Thu, 15 Nov 2018 17:55:15 +0100

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>))

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)))

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:

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

reply via email to

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