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 recursive object methods #1432

Closed
erickt opened this issue Jan 5, 2012 · 2 comments
Closed

allow recursive object methods #1432

erickt opened this issue Jan 5, 2012 · 2 comments

Comments

@erickt
Copy link
Contributor

erickt commented Jan 5, 2012

It's a bit obnoxious when writing an object type that can return instances of itself that we need a tag to break up the recursion:

tag foo_tag = foo;

type foo = obj {
    fn get_children() -> [foo_tag];
};

obj new_foo() {
  fn get_children() -> [foo_tag] { [] }
}

It'd be much nicer if rust would just let us write fn get_children() -> [foo].

@nikomatsakis
Copy link
Contributor

this is a particular instance of the fact that rust doesn't support recursive structural types (it's not really specific to objects). replacing objects with pcwalton-style classes/interfaces (which are nominally typed) would address this problem.

@marijnh
Copy link
Contributor

marijnh commented Jan 13, 2012

No longer an issue on ifaces. Closing.

@marijnh marijnh closed this as completed Jan 13, 2012
bjorn3 added a commit to bjorn3/rust that referenced this issue Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants