May 09, 2012
Yeah, that's what I did. I replaced it with opEquals(typeof(null)).

On Wed, May 9, 2012 at 8:45 PM, Steven Schveighoffer <schveiguy@yahoo.com> wrote:
> On Wed, 09 May 2012 12:17:30 -0400, Gor Gyolchanyan <gor.f.gyolchanyan@gmail.com> wrote:
>
>> I didn't know structs actually have an "is" operator. Good to know,
>> there's a way to memcmp them this way.
>> But being able to overload it wouldn't do any damage. The overloader
>> of "is" should clearly know, that "is" is an identity check and not an
>> arbitrary domain-specific equality check.
>> Overloading "is" gives a syntax sugar for nullable structures and an
>> optimization opportunity for large ones (for example a CRC checksum
>> comparison).
>
>
> The fact that it's not overloadable is useful in many situations.  There are certain cases you are truly looking for physical equality, and not logical equality.
>
> Generally, if you want logical equality, use opEquals.
>
> -Steve



-- 
Bye,
Gor Gyolchanyan.
May 09, 2012
Btw, I noticed how classes have two different comparison operators
(one for the reference and one for the object), while they have only
one assignment operator (for the reference only),
I think having two assignment operators would be very good for a
number of cases. Combined with a "final class" declaration it would
essentially be a reference type struct with a default constructor.
I've wanted such a thing for a long time now.

On Wed, May 9, 2012 at 8:48 PM, Steven Schveighoffer <schveiguy@yahoo.com> wrote:
> On Wed, 09 May 2012 12:21:05 -0400, Gor Gyolchanyan <gor.f.gyolchanyan@gmail.com> wrote:
>
>> If "is" was overloadable, one could make a legitimate reference types via structs. The opAssign would change the reference, opEquals would call the opEquals of the referred object, opBinary(string op : `is`) would compare the references... Just like classes.
>
>
> Yes, this is probably the only legitimate use case.  I'm not sure how to make it work, exactly.  But the functionality of 'is' should not be affected, it's too valuable the way it is to change it.
>
> -Steve



-- 
Bye,
Gor Gyolchanyan.
May 09, 2012
On 2012-05-09 18:13, Steven Schveighoffer wrote:

> This also works too:
>
> int opBinary(string s: "booya!")(...)
>

We could create new operators :)


-- 
/Jacob Carlborg
May 09, 2012
On Wed, 09 May 2012 16:25:35 -0400, Jacob Carlborg <doob@me.com> wrote:

> On 2012-05-09 18:13, Steven Schveighoffer wrote:
>
>> This also works too:
>>
>> int opBinary(string s: "booya!")(...)
>>
>
> We could create new operators :)

Is there a unicode glyph for fist pump? :)

-Steve
May 09, 2012
On Wed, May 09, 2012 at 05:04:59PM -0400, Steven Schveighoffer wrote:
> On Wed, 09 May 2012 16:25:35 -0400, Jacob Carlborg <doob@me.com> wrote:
> 
> >On 2012-05-09 18:13, Steven Schveighoffer wrote:
> >
> >>This also works too:
> >>
> >>int opBinary(string s: "booya!")(...)
> >>
> >
> >We could create new operators :)
> 
> Is there a unicode glyph for fist pump? :)
[...]

U+270A?

:-)


T

-- 
"I speak better English than this villain Bush" -- Mohammed Saeed al-Sahaf, Iraqi Minister of Information
May 09, 2012
On 05/09/2012 06:05 PM, H. S. Teoh wrote:
> On Wed, May 09, 2012 at 05:04:59PM -0400, Steven Schveighoffer wrote:
>> On Wed, 09 May 2012 16:25:35 -0400, Jacob Carlborg<doob@me.com>  wrote:
>>
>>> On 2012-05-09 18:13, Steven Schveighoffer wrote:
>>>
>>>> This also works too:
>>>>
>>>> int opBinary(string s: "booya!")(...)
>>>>
>>>
>>> We could create new operators :)
>>
>> Is there a unicode glyph for fist pump? :)
> [...]
>
> U+270A?
>
> :-)
>
>
> T
>

I can only imagine what a fistpump operator would do...
Also, this is my favorite new glyph.
May 09, 2012
I think it would be a unary prefix operator, which returns the operand's copy, but with double the storage, having the second half - wasted. :-D

On Thu, May 10, 2012 at 2:33 AM, Matt Soucy <msoucy@csh.rit.edu> wrote:
> On 05/09/2012 06:05 PM, H. S. Teoh wrote:
>>
>> On Wed, May 09, 2012 at 05:04:59PM -0400, Steven Schveighoffer wrote:
>>>
>>> On Wed, 09 May 2012 16:25:35 -0400, Jacob Carlborg<doob@me.com>  wrote:
>>>
>>>> On 2012-05-09 18:13, Steven Schveighoffer wrote:
>>>>
>>>>> This also works too:
>>>>>
>>>>> int opBinary(string s: "booya!")(...)
>>>>>
>>>>
>>>> We could create new operators :)
>>>
>>>
>>> Is there a unicode glyph for fist pump? :)
>>
>> [...]
>>
>> U+270A?
>>
>> :-)
>>
>>
>> T
>>
>
> I can only imagine what a fistpump operator would do... Also, this is my favorite new glyph.



-- 
Bye,
Gor Gyolchanyan.
May 10, 2012
On 2012-05-10 00:05, H. S. Teoh wrote:
> On Wed, May 09, 2012 at 05:04:59PM -0400, Steven Schveighoffer wrote:

>> Is there a unicode glyph for fist pump? :)
> [...]
>
> U+270A?
>
> :-)

Haha :)


-- 
/Jacob Carlborg
1 2
Next ›   Last »