Skip to content

Comments

Fix Issue 17684 - [REG 2.062] static alias this#7055

Merged
MartinNowak merged 1 commit intodlang:stablefrom
JinShil:stable
Aug 3, 2017
Merged

Fix Issue 17684 - [REG 2.062] static alias this#7055
MartinNowak merged 1 commit intodlang:stablefrom
JinShil:stable

Conversation

@JinShil
Copy link
Contributor

@JinShil JinShil commented Aug 2, 2017

No description provided.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @JinShil! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.

Some tips to help speed things up:

  • smaller, focused PRs are easier to review than big ones

  • try not to mix up refactoring or style changes with bug fixes or feature enhancements

  • provide helpful commit messages explaining the rationale behind each change

Bear in mind that large or tricky changes may require multiple rounds of review and revision.

Please see CONTRIBUTING.md for more information.

Bugzilla references

Auto-close Bugzilla Description
17684 [REG 2.062] static alias this bug or incomplete implementation?

@PetarKirov
Copy link
Member

PetarKirov commented Aug 2, 2017

It looks like the Jenkins failure was due to network issues, so I've restarted the test pipeline there.

StaticStruct = 42;
immutable int a = StaticStruct;
assert(a == 42);
} No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing final end of line. Consider setting up EditorConfig on your text editor, so that repo text editor settings - https://github.com/dlang/dmd/blob/master/.editorconfig - are automatically applied.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks for the review.

Copy link
Member

@PetarKirov PetarKirov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me on a first glance, though expect more thorough review from the dmd devs.

@MartinNowak
Copy link
Member

Weird language feature, but rather have it fully-working that half-working. Any specific use-case in mind?

@MartinNowak MartinNowak merged commit 9df5522 into dlang:stable Aug 3, 2017
@JinShil
Copy link
Contributor Author

JinShil commented Aug 4, 2017

Any specific use-case in mind?

Yes, it's for my memory-mapped-io library where all registers and bitfields are modeled as static entities. I currently have to put a .value any time I use a register or bitfield, which is verbose, redundant, and monotonous especially given the number of times registers must be used in a typical embedded board support package (BSP). static alias this allows me to write int baudRate = UART.BR; instead of int baudRate = UART.BR.value;, making the code more pleasant to use and read.

You'd probably question the pattern I've used in that library, but it was chosen due to other limitations in the D language (e.g. modules-must-be-files and a few others). It would take a detailed blog post to explain it, so if you really want to know, contact me offline. Long story short...it wasn't arrived at thoughtlessly.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants