I’ve been working on an extension to Dialog allowing custom structs (what Inform calls “composite kinds of value”, single values made up of multiple numbers). Most of it works perfectly. However, there’s a certain thing that seems to cause serious problems for the compiler.
If I have a parsing predicate like this:
(interface (understand $<Words as frequency $>Freq))
(understand $Words as frequency $Freq)
%% get $First and $Second somehow
($Freq = [#kovmarker @frequency $First $Second])
…then everything works fine. But if the predicate looks like this:
(interface (understand $<Words as frequency $>Freq))
(understand $Words as frequency $Freq)
%% get $First and $Second somehow
(struct $Freq has tag @frequency and contents [$First $Second])
(struct $Struct has tag $Tag and contents $Contents)
($Struct = [#kovmarker $Tag | $Contents])
…then the debugger gives a truly frightening litany of hundreds and hundreds of warnings, along the lines of
Warning: stdlib.dg, line 1776: Argument 1 of now-expression can be unbound, leading to runtime errors.
What’s so different about these two implementations? I’d thought it would be nice and elegant to have a single predicate that can pack or unpack a struct, depending which arguments are bound and which aren’t—and while it does work as expected in my test cases, the warnings make me think I’m likely preventing some optimizations. (If nothing else, I don’t want to frighten people who use the extension, or cause their own warnings to be lost in the flood.)