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

Features for working with custom types #2248

Closed
johnmyleswhite opened this issue Feb 9, 2013 · 1 comment
Closed

Features for working with custom types #2248

johnmyleswhite opened this issue Feb 9, 2013 · 1 comment
Labels
types and dispatch Types, subtyping and method dispatch

Comments

@johnmyleswhite
Copy link
Member

Some recurring design patterns in Julia that could benefit from becoming formal language constructs:

  • Delegation: You build a type that wraps another type. For example, you build a Corpus composite type, which is a collection of Documents stored in an Array along with some metadata. You'd like to delegate functions like size, length and ref to fields of this composite type. Some basic examples are shown below.
  • Interfaces: Often, we use abstract types like OO languages would use interfaces. This raises a few difficulties: the foremost is that we don't provide any mechanism for insuring that a subtype of an abstract type fully implements a specified interface.

Examples of a @delegate macro: @delegate Corpus.documents size length ref.

Examples of an @interface macro: https://gist.github.com/pao/2432554

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

No branches or pull requests

5 participants