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

spec: Document rules for recursive type and other self-referential decls #5069

Open
nico opened this issue Mar 18, 2013 · 5 comments

Comments

@nico
Copy link

commented Mar 18, 2013

The spec says "An interface type T may not embed itself or any interface type that
embeds T, recursively.", but nothing like this is mentioned for structs.

(A struct containing itself would obviously need infty memory, but the spec should
probably still explicitly mention that these are illegal while a struct containing a
pointer to itself is fine
@robpike

This comment has been minimized.

Copy link
Contributor

commented Mar 18, 2013

Comment 1:

It could embed a pointer to itself, though, and that works just fine. It's pointless to
embed a non-pointer recursively this way. Is that really worth explaining in the spec?
@griesemer

This comment has been minimized.

Copy link
Contributor

commented Apr 1, 2013

Comment 2:

This applies also to named fields for structs, and arrays, too.
In general, all "composite value types" cannot contain themselves directly or indirectly
unless there's a reference type between.
It's somewhat obvious but it probably should be spec'ed out explicitly, after all it's
something that typecheckers go though some length to check.

Labels changed: added documentation.

Owner changed to @griesemer.

Status changed to Accepted.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Nov 27, 2013

Comment 3:

Labels changed: added go1.3maybe.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Dec 4, 2013

Comment 4:

Labels changed: added release-none, removed go1.3maybe.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Dec 4, 2013

Comment 5:

Labels changed: added repo-main.

@rsc rsc added this to the Unplanned milestone Apr 10, 2015

@rsc rsc removed release-none labels Apr 10, 2015

@griesemer griesemer changed the title spec: Recursive structs aren't mentioned spec: Document rules for recursive type decls and other self-referential decls Jan 7, 2016

@griesemer griesemer changed the title spec: Document rules for recursive type decls and other self-referential decls spec: Document rules for recursive type and other self-referential decls Jan 7, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.