Re: Custom state variables
Marc Nieper-Wißkirchen 15 Feb 2019 07:26 UTC
Am Mo., 11. Feb. 2019 um 10:43 Uhr schrieb Alex Shinn <xxxxxx@gmail.com>:
[...]
> On Mon, Feb 11, 2019 at 4:10 PM Marc Nieper-Wißkirchen <xxxxxx@nieper-wisskirchen.de> wrote:
>>
>> Am Mo., 11. Feb. 2019 um 08:18 Uhr schrieb Alex Shinn <xxxxxx@gmail.com>:
>> >
>> >
>> > It's worse than that though, since the identifiers conflict with themselves - you're likely to want nested formatters referring to the `col` variable (the ref impl does this), for instance, and this would no longer be possible without renaming.
>>
>> Maybe I don't understand the problem, but isn't the simple solution to
>> write, say, `(fn ((%col col)) ...)' instead of `(fn ((col col)) ...)'
>> or `(fn (col) ...)' in these cases?
>
>
> Yep, that's what I meant by "renaming." I'm not sure how often this will bite people.
SRFI 99 uses datum->syntax (though not part of R7RS-small) to make up
constructor and predicate names for record types (by adding a prefix
like "make-" or a suffix like "?") when they are not explicitly given.
Using the same technique, "(fn (col) ...)" could expand into "(fn
((col state-var-col)) ...)", where "state-var-" is some documented
prefix. SRFI 159 (and derived libraries providing further formatters)
would then have to export state variables under two names, one without
and one with the prefix.
I'm not saying that I like this solution (it's very unhygienic in a
different way) but it would remove the necessity of renaming "col" by
"%col" by hand.
[...]
Marc