[plt-scheme] Applying DRY in macros
Dan Prager skrev:
> Noel and especially Jens
>
> Thanks for your replies. I agree that Jens's solution succeeds in
> demonstrating a
> 'magic' approach using syntax-case, albeit at the cost of increasing
> complexity.
>
> Noel's point that you cannot 'or' patterns in syntax-rules[case]
> excludes another
> idea for eliminating the repetition.
>
> Another possibility, creating a macro-generating macro to allow for
> briefer 'magic' definitions
> or to permit the or-ing patterns are certainly beyond me and I imagine
> that neither is an easy task.
> I take it that Jens's comment about 'explicit transfer' in his
> solution connotes that 'implicit transfer'
> could not be easily achieved.
That's a bit much to read into it. Since no one has implemented
magic-syntax-rules yet,
so to show how magic-syntax-rules would work, one must use what is
available,
namely syntax-case. The hard part of implementing magic-syntax-rules is to
figure out what it does in detail. When the semantics are in place, all
that's left
to do is to use syntax-case to implement it.
write a syntax-
> As to whether the repeated sexp (for list as element body ...)
> constitutes repetition,
> I would say that it is certainly a textual duplicate!
I think, that in order to count as real duplication of code, the two
occurences
should *mean* the same thing.
In this sentence
First Alice said "Bob", then Alice said "Charlie".
there is duplication (Alice is repeated twice with the same meaning),
so one normally rephrases it as:
First Alice said "Bob", then she said "Charlie".
Now consider the sentence:
Dan says "Dan".
Is there duplication here?
--
Jens Axel Søgaard