Jump to page: 1 26  
Page
Thread overview
clear() and UFCS
May 25, 2012
Dmitry Olshansky
May 25, 2012
deadalnix
May 25, 2012
deadalnix
May 25, 2012
deadalnix
May 25, 2012
Mirko Pilger
May 26, 2012
Francisco Almeida
May 26, 2012
David Nadlinger
May 25, 2012
sclytrack
May 25, 2012
Brad Anderson
May 25, 2012
John Chapman
May 26, 2012
Mehrdad
May 26, 2012
Jonathan M Davis
May 26, 2012
Mehrdad
May 26, 2012
Jonathan M Davis
May 26, 2012
Mehrdad
May 26, 2012
Jonathan M Davis
May 26, 2012
Mehrdad
May 26, 2012
Mehrdad
May 26, 2012
jerro
May 26, 2012
sclytrack
May 26, 2012
RivenTheMage
May 26, 2012
Era Scarecrow
May 26, 2012
Jacob Carlborg
May 26, 2012
Michel Fortin
May 26, 2012
Jonathan M Davis
May 26, 2012
Dmitry Olshansky
May 29, 2012
Simen Kjaeraas
May 26, 2012
Joshua Niehus
May 26, 2012
Ary Manzana
May 25, 2012
Sönke Ludwig
May 25, 2012
Artur Skawina
May 30, 2012
Jonathan M Davis
May 25, 2012
So I was writing a container class and in some test code, I called container.clear(). Reasonable enough, right? Hell, it even compiled!

Turns out, my program completely broke at runtime. Apparently, I'd forgotten to implement clear() on my container class, and *object.clear() was being called instead*.

I don't blame UFCS for this. It just happened to be the reason this compiled at all. But, what I do think is: clear is the *ABSOLUTELY MOST HORRIBLE NAME EVER* for a function that actually finalizes and zeroes an object. Did it not seem obvious to call it, I don't know, *finalize*? And even ignoring the naming, having a symbol called clear in the 'global' namespace is absolute insanity.

Am I the only person with this opinion?

-- 
Alex Rønne Petersen
alex@lycus.org
http://lycus.org
May 25, 2012
On 25.05.2012 17:04, Alex Rønne Petersen wrote:
> So I was writing a container class and in some test code, I called
> container.clear(). Reasonable enough, right? Hell, it even compiled!
>
> Turns out, my program completely broke at runtime. Apparently, I'd
> forgotten to implement clear() on my container class, and
> *object.clear() was being called instead*.
>
> I don't blame UFCS for this. It just happened to be the reason this
> compiled at all. But, what I do think is: clear is the *ABSOLUTELY MOST
> HORRIBLE NAME EVER* for a function that actually finalizes and zeroes an
> object. Did it not seem obvious to call it, I don't know, *finalize*?
> And even ignoring the naming, having a symbol called clear in the
> 'global' namespace is absolute insanity.
>
> Am I the only person with this opinion?
>

No, there are thousands like you. Let's call clear "nuke", breaking TDPL and saving the day. :)

P.S. Obviously first clear goes through normal deprecation cycle.

-- 
Dmitry Olshansky
May 25, 2012
Le 25/05/2012 15:04, Alex Rønne Petersen a écrit :
> So I was writing a container class and in some test code, I called
> container.clear(). Reasonable enough, right? Hell, it even compiled!
>
> Turns out, my program completely broke at runtime. Apparently, I'd
> forgotten to implement clear() on my container class, and
> *object.clear() was being called instead*.
>
> I don't blame UFCS for this. It just happened to be the reason this
> compiled at all. But, what I do think is: clear is the *ABSOLUTELY MOST
> HORRIBLE NAME EVER* for a function that actually finalizes and zeroes an
> object. Did it not seem obvious to call it, I don't know, *finalize*?
> And even ignoring the naming, having a symbol called clear in the
> 'global' namespace is absolute insanity.
>
> Am I the only person with this opinion?
>

Why is UFCS involved here ?
May 25, 2012
On 25-05-2012 15:17, deadalnix wrote:
> Le 25/05/2012 15:04, Alex Rønne Petersen a écrit :
>> So I was writing a container class and in some test code, I called
>> container.clear(). Reasonable enough, right? Hell, it even compiled!
>>
>> Turns out, my program completely broke at runtime. Apparently, I'd
>> forgotten to implement clear() on my container class, and
>> *object.clear() was being called instead*.
>>
>> I don't blame UFCS for this. It just happened to be the reason this
>> compiled at all. But, what I do think is: clear is the *ABSOLUTELY MOST
>> HORRIBLE NAME EVER* for a function that actually finalizes and zeroes an
>> object. Did it not seem obvious to call it, I don't know, *finalize*?
>> And even ignoring the naming, having a symbol called clear in the
>> 'global' namespace is absolute insanity.
>>
>> Am I the only person with this opinion?
>>
>
> Why is UFCS involved here ?

Since the clear method didn't exist on the type, the call was mapped to the clear function in the global scope. This is UFCS.

-- 
Alex Rønne Petersen
alex@lycus.org
http://lycus.org
May 25, 2012
Le 25/05/2012 15:21, Alex Rønne Petersen a écrit :
> On 25-05-2012 15:17, deadalnix wrote:
>> Le 25/05/2012 15:04, Alex Rønne Petersen a écrit :
>>> So I was writing a container class and in some test code, I called
>>> container.clear(). Reasonable enough, right? Hell, it even compiled!
>>>
>>> Turns out, my program completely broke at runtime. Apparently, I'd
>>> forgotten to implement clear() on my container class, and
>>> *object.clear() was being called instead*.
>>>
>>> I don't blame UFCS for this. It just happened to be the reason this
>>> compiled at all. But, what I do think is: clear is the *ABSOLUTELY MOST
>>> HORRIBLE NAME EVER* for a function that actually finalizes and zeroes an
>>> object. Did it not seem obvious to call it, I don't know, *finalize*?
>>> And even ignoring the naming, having a symbol called clear in the
>>> 'global' namespace is absolute insanity.
>>>
>>> Am I the only person with this opinion?
>>>
>>
>> Why is UFCS involved here ?
>
> Since the clear method didn't exist on the type, the call was mapped to
> the clear function in the global scope. This is UFCS.
>

OK, I get it ! Weird side effect :D

BTW, where is the documentation about clear and emplace ? I can't find it on dlang.org .
May 25, 2012
On 25-05-2012 16:50, deadalnix wrote:
> Le 25/05/2012 15:21, Alex Rønne Petersen a écrit :
>> On 25-05-2012 15:17, deadalnix wrote:
>>> Le 25/05/2012 15:04, Alex Rønne Petersen a écrit :
>>>> So I was writing a container class and in some test code, I called
>>>> container.clear(). Reasonable enough, right? Hell, it even compiled!
>>>>
>>>> Turns out, my program completely broke at runtime. Apparently, I'd
>>>> forgotten to implement clear() on my container class, and
>>>> *object.clear() was being called instead*.
>>>>
>>>> I don't blame UFCS for this. It just happened to be the reason this
>>>> compiled at all. But, what I do think is: clear is the *ABSOLUTELY MOST
>>>> HORRIBLE NAME EVER* for a function that actually finalizes and
>>>> zeroes an
>>>> object. Did it not seem obvious to call it, I don't know, *finalize*?
>>>> And even ignoring the naming, having a symbol called clear in the
>>>> 'global' namespace is absolute insanity.
>>>>
>>>> Am I the only person with this opinion?
>>>>
>>>
>>> Why is UFCS involved here ?
>>
>> Since the clear method didn't exist on the type, the call was mapped to
>> the clear function in the global scope. This is UFCS.
>>
>
> OK, I get it ! Weird side effect :D
>
> BTW, where is the documentation about clear and emplace ? I can't find
> it on dlang.org .

I think clear() is basically entirely undocumented still.

-- 
Alex Rønne Petersen
alex@lycus.org
http://lycus.org
May 25, 2012
On Fri, 25 May 2012 10:52:15 -0400, Alex Rønne Petersen <alex@lycus.org> wrote:

> On 25-05-2012 16:50, deadalnix wrote:
>> Le 25/05/2012 15:21, Alex Rønne Petersen a écrit :
>>> On 25-05-2012 15:17, deadalnix wrote:
>>>> Le 25/05/2012 15:04, Alex Rønne Petersen a écrit :
>>>>> So I was writing a container class and in some test code, I called
>>>>> container.clear(). Reasonable enough, right? Hell, it even compiled!
>>>>>
>>>>> Turns out, my program completely broke at runtime. Apparently, I'd
>>>>> forgotten to implement clear() on my container class, and
>>>>> *object.clear() was being called instead*.
>>>>>
>>>>> I don't blame UFCS for this. It just happened to be the reason this
>>>>> compiled at all. But, what I do think is: clear is the *ABSOLUTELY MOST
>>>>> HORRIBLE NAME EVER* for a function that actually finalizes and
>>>>> zeroes an
>>>>> object. Did it not seem obvious to call it, I don't know, *finalize*?
>>>>> And even ignoring the naming, having a symbol called clear in the
>>>>> 'global' namespace is absolute insanity.
>>>>>
>>>>> Am I the only person with this opinion?
>>>>>
>>>>
>>>> Why is UFCS involved here ?
>>>
>>> Since the clear method didn't exist on the type, the call was mapped to
>>> the clear function in the global scope. This is UFCS.
>>>
>>
>> OK, I get it ! Weird side effect :D
>>
>> BTW, where is the documentation about clear and emplace ? I can't find
>> it on dlang.org .
>
> I think clear() is basically entirely undocumented still.

Wow, you're right, it's not documented.  That should be fixed!

-Steve
May 25, 2012
On 5/25/12 8:06 AM, Dmitry Olshansky wrote:
> On 25.05.2012 17:04, Alex Rønne Petersen wrote:
>> So I was writing a container class and in some test code, I called
>> container.clear(). Reasonable enough, right? Hell, it even compiled!
>>
>> Turns out, my program completely broke at runtime. Apparently, I'd
>> forgotten to implement clear() on my container class, and
>> *object.clear() was being called instead*.
>>
>> I don't blame UFCS for this. It just happened to be the reason this
>> compiled at all. But, what I do think is: clear is the *ABSOLUTELY MOST
>> HORRIBLE NAME EVER* for a function that actually finalizes and zeroes an
>> object. Did it not seem obvious to call it, I don't know, *finalize*?
>> And even ignoring the naming, having a symbol called clear in the
>> 'global' namespace is absolute insanity.
>>
>> Am I the only person with this opinion?
>>
>
> No, there are thousands like you. Let's call clear "nuke", breaking TDPL
> and saving the day. :)
>
> P.S. Obviously first clear goes through normal deprecation cycle.

Since this is a recurring issue we should probably change the name.

Andrei


May 25, 2012
On 25-05-2012 16:56, Steven Schveighoffer wrote:
> On Fri, 25 May 2012 10:52:15 -0400, Alex Rønne Petersen
> <alex@lycus..org> wrote:
>
>> On 25-05-2012 16:50, deadalnix wrote:
>>> Le 25/05/2012 15:21, Alex Rønne Petersen a écrit :
>>>> On 25-05-2012 15:17, deadalnix wrote:
>>>>> Le 25/05/2012 15:04, Alex Rønne Petersen a écrit :
>>>>>> So I was writing a container class and in some test code, I called
>>>>>> container.clear(). Reasonable enough, right? Hell, it even compiled!
>>>>>>
>>>>>> Turns out, my program completely broke at runtime. Apparently, I'd
>>>>>> forgotten to implement clear() on my container class, and
>>>>>> *object.clear() was being called instead*.
>>>>>>
>>>>>> I don't blame UFCS for this. It just happened to be the reason this
>>>>>> compiled at all. But, what I do think is: clear is the *ABSOLUTELY
>>>>>> MOST
>>>>>> HORRIBLE NAME EVER* for a function that actually finalizes and
>>>>>> zeroes an
>>>>>> object. Did it not seem obvious to call it, I don't know, *finalize*?
>>>>>> And even ignoring the naming, having a symbol called clear in the
>>>>>> 'global' namespace is absolute insanity.
>>>>>>
>>>>>> Am I the only person with this opinion?
>>>>>>
>>>>>
>>>>> Why is UFCS involved here ?
>>>>
>>>> Since the clear method didn't exist on the type, the call was mapped to
>>>> the clear function in the global scope. This is UFCS.
>>>>
>>>
>>> OK, I get it ! Weird side effect :D
>>>
>>> BTW, where is the documentation about clear and emplace ? I can't find
>>> it on dlang.org .
>>
>> I think clear() is basically entirely undocumented still.
>
> Wow, you're right, it's not documented. That should be fixed!
>
> -Steve

We actually have tons of documentation that still encourages using delete...

-- 
Alex Rønne Petersen
alex@lycus.org
http://lycus.org
May 25, 2012
On 25-05-2012 16:56, Steven Schveighoffer wrote:
> On Fri, 25 May 2012 10:52:15 -0400, Alex Rønne Petersen
> <alex@lycus..org> wrote:
>
>> On 25-05-2012 16:50, deadalnix wrote:
>>> Le 25/05/2012 15:21, Alex Rønne Petersen a écrit :
>>>> On 25-05-2012 15:17, deadalnix wrote:
>>>>> Le 25/05/2012 15:04, Alex Rønne Petersen a écrit :
>>>>>> So I was writing a container class and in some test code, I called
>>>>>> container.clear(). Reasonable enough, right? Hell, it even compiled!
>>>>>>
>>>>>> Turns out, my program completely broke at runtime. Apparently, I'd
>>>>>> forgotten to implement clear() on my container class, and
>>>>>> *object.clear() was being called instead*.
>>>>>>
>>>>>> I don't blame UFCS for this. It just happened to be the reason this
>>>>>> compiled at all. But, what I do think is: clear is the *ABSOLUTELY
>>>>>> MOST
>>>>>> HORRIBLE NAME EVER* for a function that actually finalizes and
>>>>>> zeroes an
>>>>>> object. Did it not seem obvious to call it, I don't know, *finalize*?
>>>>>> And even ignoring the naming, having a symbol called clear in the
>>>>>> 'global' namespace is absolute insanity.
>>>>>>
>>>>>> Am I the only person with this opinion?
>>>>>>
>>>>>
>>>>> Why is UFCS involved here ?
>>>>
>>>> Since the clear method didn't exist on the type, the call was mapped to
>>>> the clear function in the global scope. This is UFCS.
>>>>
>>>
>>> OK, I get it ! Weird side effect :D
>>>
>>> BTW, where is the documentation about clear and emplace ? I can't find
>>> it on dlang.org .
>>
>> I think clear() is basically entirely undocumented still.
>
> Wow, you're right, it's not documented. That should be fixed!
>
> -Steve

Before we do, we should deprecate clear and rename it to finalize, though.

-- 
Alex Rønne Petersen
alex@lycus.org
http://lycus.org
« First   ‹ Prev
1 2 3 4 5 6