| |
| Posted by Uranuz | PermalinkReply |
|
Uranuz
| https://forum.dlang.org/post/uo1jj3$151c$1@digitalmars.com
On Sunday, 14 January 2024 at 21:27:00 UTC, Walter Bright wrote:
> On 1/11/2024 12:33 PM, Dennis wrote:
>> On Thursday, 11 January 2024 at 19:21:46 UTC, Walter Bright wrote:
>>> It's ok if the error is detected after instantiation. It can be detected by testing to see if the mangled signature (which is generated for the type of the function) already exists.
>>
>> That is the second option I listed in my opening post, which can be implemented easily.
>> However, it would create a compile time 'race condition': the `f!short` instantiation which dmd sees first may succeed, but any subsequent attempts will fail.
>>
>> I don't know if this will result in inscrutable errors in practice, but it very well may.
>
>
> string f(T)(T x) if (T.sizeof <= 2) { return "x"; }
> string f(T)(T y) if (T.sizeof >= 2) { return "y"; }
>
> Then the only thing to do is disallow an overload that differs only in the parameter names.
Hello! I have a question. Why you decided to use ":" symbol as separator of name and value of parameter in function call syntax? For aestetical reason "=" looks better (at my opinion).
f(x=2, y=10)
Maybe this is because I have Python background where "=" is used for this? ;-)
But in static initializer syntax ":" symbol looks better for me:
struct A {
int a;
int b;
};
{ a: 1, b: 2 }
Maybe it is because I also have Python and JavaScript background? So it looks like JSON format.
Also one thing in D that I still cannot accomodate to is associative array literals with [square brackets]. I'am used to that JSON, JavaScript objects use curly {curly braces} for object literal. And also this is the same for Python.
{ "a": 3, "b": 4 }
But in dlang I should use:
[ "a": 3, "b": 4 ]
This is a little confusing, because I develop web application in D and JavaScript. So I need to rememeber this difference in basic syntax every time.
I understand that this is kind of *holly war* theme. But it's still interesting
|