I’ve seen some built-in constructions in Inform which use commas to add modifying clauses, for example this one from the docs on Lists:
let D be S;
remove T from D, if present;
I thought maybe I could do the same thing with my own action. Create a version of the action, then a second version with the comma clause at the end ‘, taking no time’ - to make a non-turn passing version.
For awhile I thought this was working. Eventually I hit weird behaviour in my project, then realised it was because the comma clause thing was silently not working, and the version without any comma was always going to the version WITH the comma.
Here is a demo 1. After ‘test me’, you’d expect the first test to return ‘I danced’ and the second to return ‘I danced and twirled’, but they both return ‘I danced and twirled’.
[rant][code]“Dancing, twirling 1”
Ballroom is a room.
[Test 1]
To dance:
say “I danced.”;
[Test2]
To dance, twirling:
say “I danced, twirling.”;
wanting to run test1 is an action applying to nothing.
Understand “t1” as wanting to run test1.
Carry out wanting to run test1:
dance;
wanting to run test2 is an action applying to nothing.
Understand “t2” as wanting to run test2.
Carry out wanting to run test2:
dance, twirling;
test me with “t1 / t2”.[/code][/rant]
But then!.. I discovered that if I reversed the order these two action definitions appear in the source, the scheme works, as in demo 2:
[rant][code]“Dancing, twirling 2”
Ballroom is a room.
[Test2]
To dance, twirling:
say “I danced, twirling.”;
[Test 1]
To dance:
say “I danced.”;
wanting to run test1 is an action applying to nothing.
Understand “t1” as wanting to run test1.
Carry out wanting to run test1:
dance;
wanting to run test2 is an action applying to nothing.
Understand “t2” as wanting to run test2.
Carry out wanting to run test2:
dance, twirling;
test me with “t1 / t2”.[/code][/rant]
Is this whole thing a bug, or unexpected behaviour that’s slipped through and shouldn’t work at all? Or that should be working but isn’t? I would want to check before thinking about relying on it in any way.
Of course, a safer fix is to just remove the comma.
-Wade