Skip to content

Remove get_* on getters as per RFC 0344 #6224

Closed

Description

@frewsxcv

In an effort to:

  1. Follow the agreed upon conventions (see the RFC section below)
  2. Make our internal Servo APIs more ergonomic (shorter in this case)
  3. Assist in completing the uncompletable issue Servo's code should be beautiful #130

I propose we remove the get_ prefix on most getters in the codebase.

If the glorious leaders of Servo approve this, I (@frewsxcv) would be willing to take on this momentous feat.

RFC

A method foo(&self) -> &T for getting the current value of the field.
A method set_foo(&self, val: T) for setting the field. (The val argument here may take &T or some other type, depending on the context.)

-- RFC 0344 § Getter/setter APIs

Activity

  1. Manishearth commented on May 31, 2015

    @Manishearth
    Member

    +1

    Within the DOM we do this already, but somehow all unsafe layouty methods and bindings still have this.

    Avoid touching script/ until the SM upgrade passes.

    Servo and Rust don't really follow the style for Rust-y code in their internals (partially because they've been around for very long and fixing style to fix the fluid "prevailing" style is very low priority), but that doesn't mean we shouldn't try.

  2. Manishearth commented on May 31, 2015

    @Manishearth
    Member

    Actually, come to think of it I prefer having get_ on unsafe methods (very common in layout <-> DOM). When calling unsafe methods you should know what's happening, and get_ emphasizes that it's just a getter (and you know what invariants must be satisfied for the usage to be safe)

  3. frewsxcv commented on May 31, 2015

    @frewsxcv
    ContributorAuthor

    Actually, come to think of it I prefer having get_ on unsafe methods

    Just to be absolutely clear, do you believe that none of the APIs should change or should I just avoid the unsafe ones (in addition to the script/ ones)

  4. Manishearth commented on May 31, 2015

    @Manishearth
    Member

    Just avoid the unsafe ones and the script ones (unless pcwalton or someone else who uses them regularly is okay with it). Most of the unsafe ones are in script anyway.

  5. added a commit that references this issue on Jun 2, 2015
  6. nox commented on Jun 2, 2015

    @nox
    Contributor

    Never mind.

  7. reopened this on Jun 2, 2015
  8. added
    I-refactor
    on Aug 2, 2015
  9. added 3 commits that reference this issue on Sep 11, 2015
  10. frewsxcv commented on Sep 13, 2015

    @frewsxcv
    ContributorAuthor

    I'm pretty satisfied with the work that's been done towards this. There might be a few remaining but it's probably not worth it to keep this open

  11. added a commit that references this issue on Apr 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions