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

Re: pattern variable coercion



Gabor Greif gabor@mac.com on  2000-05-06 08:00 wrote:

> While reading "Dylan Programming" I stumbled over coercion of pattern
> variables. (page 368)
> 
> Here is a contrived example:
> 
> define macro symbolize
> { symbolize(?:name) } => { ?#"name" }
> end macro symbolize;
> 
> I could not derive this syntax from the BNF in the DRM. Is this a
> Harlequinism?

It is permitted by the BNF.  Look at substitution on p. 429 of the DRM and
you will see that ? can be followed by NAME, STRING, or SYMBOL.  I grant
you, you couldn't be expected to guess why, though.
 
[...]

> I regard pattern variable coercion as a rather essential feature.
> What coercions are supported? And what is their syntax?

The only supported coercions are to symbol (as above) and to a string (using
?"name").
 
> Where is this all documented?

Perhaps quite obscurely on p. 160 of the DRM, where substitution is
explained.
 
> Why did not make coercions their way into the DRM?

Well they did, if obscurely.  It was my hope that the chapter in DP would be
a little more transparent.



References: