Skip to content

RFC: Implement a #[derive] or #[auto] meta-syntax-extension #4970

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

Closed
nikomatsakis opened this issue Feb 15, 2013 · 4 comments
Closed

RFC: Implement a #[derive] or #[auto] meta-syntax-extension #4970

nikomatsakis opened this issue Feb 15, 2013 · 4 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@nikomatsakis
Copy link
Contributor

Right now to use deriving/auto you have to add individual annotations on types:

#[deriving_eq]
#[deriving_ord]
#[auto_encode]
#[auto_decode]
struct Foo { }

This is tedious and an eye-sore. However, it has the advantage that if some third-party X comes along and implement a trait Bar, they can implement a syntax extension #[deriving_X] that fits right in. Therefore, I propose we have a "meta" syntax extension called #[derive] or #[auto] (I will use auto in the examples that follow) that would expand the following declaration:

#[auto(Eq,Ord,Bar)]
struct Foo {}

into:

#[auto_Eq]
#[auto_Ord]
#[auto_Bar]
struct Foo {}

This makes deriving convenient to use while preserving the ability for third-parties to seamlessly integrate.

As for what to call it: auto seems like a clearer name for those not familiar with Haskell, but derive or deriving has precedent. I don't really care.

@bstrie
Copy link
Contributor

bstrie commented Feb 15, 2013

More consistent, more intuitive, and prettier. +1

@catamorphism
Copy link
Contributor

+1. I prefer deriving to auto -- auto has too many meanings.

@graydon
Copy link
Contributor

graydon commented Mar 12, 2013

Pull #5320 handles this, or at least moves in that direction.

@graydon
Copy link
Contributor

graydon commented Apr 24, 2013

landed

@graydon graydon closed this as completed Apr 24, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

4 participants