Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I use Unity in my day job, and looked into using Inform 7 with it. While it's technically possible to use the two together using the C backend, there's still quite a lot of impedance mismatch. I got permission to work about one week a quarter on a C# backend, which I started working on in March 2023. I'm pleased to report it's now in good enough shape to be able to run the
Eg1.i7
Hello World example (modulo a small, fixable issue to be described later) and I've gotten permission for it to eventually be upstreamed if you so desire.The one issue preventing use out-of-the-box is that the code generator generates a few gotos that jump into the middle of a block. C# requires gotos targets to be in the lexical scope of the goto statement. That's a pretty reasonable sounding requirement, just one that we don't adhere to. I've experimented by hand and it seems to be possible to fix the problematic code generation by lowering any blocks the target is inside into sections of code guarded by
if (!condition) goto if1;
and similar constructs. (Brings back memories of writing unstructured BASIC as a kid!) Presumably the best way to do this is to traverse the Inter tree and massage it a bit before calling the code generation on the function, but I'm open to advice on the best way to do that.The impedance mismatch can further be reduced by using the native C# class system instead of a port of the bespoke C implementation. This is not yet implemented. That should also allow greatly reducing the amount of name mangling required.
int
andbool
are different types in C#, but the code generation currently handles this complication very naively through abundant and often unnecessary calls toSystem.Convert.ToBoolean
andSystem.Convert.ToInt32
. Most of these could be avoided if the caller knew whether the output was going to be used in a boolean context.Other miscellaneous improvements needed are a comprehensive update of the text of the files to match the code and eventually to remove the comments currently generated by the backend to aid in locating the code that generated certain constructs.