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

Generic type variables #282

Closed
thekid opened this issue Dec 27, 2013 · 2 comments
Closed

Generic type variables #282

thekid opened this issue Dec 27, 2013 · 2 comments

Comments

@thekid
Copy link
Member

thekid commented Dec 27, 2013

Scope of Change

Access to the type variables declared in the @generic annotations of methods will be granted.

Rationale

Working with lang.Type's utility methods such as cast, newInstance, isInstance and its default member comes in handy in writing generic methods.,

Functionality

General idea:

#[@generic(return= 'T[]')]
public function all() {
  $r= [];
  foreach ($this->list as $value) {
    $r[]= $T->newInstance($value);
  }
  return $r;
}

Security considerations

n/a

Speed impact

Slightly slower only if type variables are used.

Dependencies

Removal of __generic left-overs from #193 in util.collections

Related documents

The experiment this RFC is based on

@thekid
Copy link
Member Author

thekid commented Aug 12, 2014

This is inconsistent with #214 as $T is a string and not a lang.Type instance.

thekid added a commit to thekid/core that referenced this issue Aug 12, 2014
thekid added a commit to xp-framework/core that referenced this issue Aug 13, 2014
@thekid thekid closed this as completed Aug 13, 2014
@thekid
Copy link
Member Author

thekid commented Aug 14, 2014

Part of XP 6, see #172

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant