Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6229973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:39:50+00:00 2026-05-24T09:39:50+00:00

Testing the following in D import std.stdio; struct S { int _val; @property ref

  • 0

Testing the following in D

import std.stdio;

struct S
{
    int _val;
    @property ref int val() { return _val; }
    @property void val(int v) { _val = v; writeln("Setter called!"); }
}

void main()
{
    auto s = S();
    s.val = 5;
}

yields "Settter called!" as the output.

What rule does the compiler use to determine whether to call the first or the second implementation?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:39:50+00:00Added an answer on May 24, 2026 at 9:39 am

    Here you are providing two @property methods, one accepts an argument, the other does not. When doing s.val = 5;, what you’re actually doing is s.val(5), but as val is a @property you can write it as a property rather than a method call (see http://d-programming-language.org/function.html#property-functions). From s.val(5) the compiler can do standard overload resolution – see http://d-programming-language.org/function.html#function-overloading.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code as a middleware in an pylons application: import testing.model
I am learning PHP PEAR and testing the following code. However when I login,
I am testing against the following test document: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE html PUBLIC
I am trying to do some Cucumber testing like the following: Given I am
Edit: closing anchor fixed. This issue exists when testing on the following browsers: Google
Following Chris Hanson's blogs and Apple's Automated Unit Testing with Xcode 3 and Objective-C
I have the following controller action and test. I'm new to testing with Shoulda
In general the SDLC has the following phase requirement gathering design coding testing deployment
Testing: return request.getCookies() == null; is not an appropriate way test. Is there another
I've added the following to my settings.py file: import logging ... logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.