Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow structures with pointers to yet undefined types. #6

Open
nsensfel opened this issue Aug 15, 2020 · 1 comment
Open

Allow structures with pointers to yet undefined types. #6

nsensfel opened this issue Aug 15, 2020 · 1 comment
Assignees
Labels
design enhancement New feature or request fate Issues relating to the Fate language

Comments

@nsensfel
Copy link
Owner

While having recursive structures is troublesome because it complicates the interpreter's implementation (copy by value on an infinitely recursive structure is... complicated), having fields with pointers to yet undefined types should not be an issue.

I'll consider it for the second version of Fate.

@nsensfel nsensfel added enhancement New feature or request design fate Issues relating to the Fate language labels Aug 15, 2020
@nsensfel nsensfel added this to the V2 - Release Candidate 0 milestone Nov 7, 2020
@nsensfel nsensfel self-assigned this Nov 7, 2020
@nsensfel
Copy link
Owner Author

The parser_rework branch added the FutureType class to Fate (to delay having to distinguish between a string and a variable name until it becomes clear whether a string would make sense). This might make it easier to add the feature:

  • Creates the YetUndeclaredType class, which extends FutureType.
  • Constructor takes a string, which is the name of the type that is expected to be declared in the future.
  • YetUndeclaredType keeps track of all created instances in a Map<String, Collection<YetUndeclaredType>>.
  • Upon any type declaration, call some static function in YetUndeclaredType to see if this resolves any of them.
  • In Fate, the user can simply use (future_type not_yet_declared_class).
  • The user might have used this to refer to a type that was already declared. This should trigger a warning, but still work.
  • The user might make infinitely recursive types. The feature should be implemented without checks for this in its first iteration (with a warning on Fate documentation not to do recursive types).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design enhancement New feature or request fate Issues relating to the Fate language
Projects
None yet
Development

No branches or pull requests

1 participant