| Thread overview | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
April 11, 2012 Re: opHash?? | ||||
|---|---|---|---|---|
| ||||
On Tuesday, April 10, 2012 18:44:40 H. S. Teoh wrote: > TDPL, p.117, last para: > > ... For a user-defined type to be used as a key in an > associative array, it must define two special methods, opHash > and opCmp. > > Really? I thought the convention was toHash (TDPL, p.205). So, which is > it? Which *should* it be? > > To me, it seems utterly arbitrary that classes should use toHash whereas non-class user-defined types should use opHash. Shouldn't we make it consistent across the board? I expect that opHash was a mistake and that there should be an errata for that line on page 117: http://erdani.com/tdpl/errata/ - Jonathan M Davis | ||||
April 11, 2012 Re: opHash?? | ||||
|---|---|---|---|---|
| ||||
On Tue, Apr 10, 2012 at 06:49:07PM -0700, Jonathan M Davis wrote: > On Tuesday, April 10, 2012 18:44:40 H. S. Teoh wrote: > > TDPL, p.117, last para: > > > > ... For a user-defined type to be used as a key in an > > associative array, it must define two special methods, opHash > > and opCmp. > > > > Really? I thought the convention was toHash (TDPL, p.205). So, which is > > it? Which *should* it be? > > > > To me, it seems utterly arbitrary that classes should use toHash whereas non-class user-defined types should use opHash. Shouldn't we make it consistent across the board? > > I expect that opHash was a mistake and that there should be an errata for that line on page 117: http://erdani.com/tdpl/errata/ [...] Actually, I looked, but it wasn't listed. Andrei? Is this an error? T -- Do not reason with the unreasonable; you lose by definition. | ||||
April 11, 2012 Re: opHash?? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | On 4/10/12 11:10 PM, H. S. Teoh wrote:
> On Tue, Apr 10, 2012 at 06:49:07PM -0700, Jonathan M Davis wrote:
>> On Tuesday, April 10, 2012 18:44:40 H. S. Teoh wrote:
>>> TDPL, p.117, last para:
>>>
>>> ... For a user-defined type to be used as a key in an
>>> associative array, it must define two special methods, opHash
>>> and opCmp.
>>>
>>> Really? I thought the convention was toHash (TDPL, p.205). So, which is
>>> it? Which *should* it be?
>>>
>>> To me, it seems utterly arbitrary that classes should use toHash whereas
>>> non-class user-defined types should use opHash. Shouldn't we make it
>>> consistent across the board?
>>
>> I expect that opHash was a mistake and that there should be an errata
>> for that line on page 117: http://erdani.com/tdpl/errata/
> [...]
>
> Actually, I looked, but it wasn't listed.
>
> Andrei? Is this an error?
Most likely!
Andrei
| |||
April 13, 2012 Re: opHash?? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Wed, Apr 11, 2012 at 09:01:41AM -0500, Andrei Alexandrescu wrote: > On 4/10/12 11:10 PM, H. S. Teoh wrote: > >On Tue, Apr 10, 2012 at 06:49:07PM -0700, Jonathan M Davis wrote: > >>On Tuesday, April 10, 2012 18:44:40 H. S. Teoh wrote: > >>>TDPL, p.117, last para: > >>> > >>> ... For a user-defined type to be used as a key in an > >>> associative array, it must define two special methods, opHash > >>> and opCmp. > >>> > >>>Really? I thought the convention was toHash (TDPL, p.205). So, which is > >>>it? Which *should* it be? > >>> > >>>To me, it seems utterly arbitrary that classes should use toHash whereas non-class user-defined types should use opHash. Shouldn't we make it consistent across the board? > >> > >>I expect that opHash was a mistake and that there should be an errata for that line on page 117: http://erdani.com/tdpl/errata/ > >[...] > > > >Actually, I looked, but it wasn't listed. > > > >Andrei? Is this an error? > > Most likely! [...] So this should be added to the errata, then? T -- In theory, there is no difference between theory and practice. | |||
April 13, 2012 Re: opHash?? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | On 4/13/12 12:15 PM, H. S. Teoh wrote:
> So this should be added to the errata, then?
I'm on it.
Andrei
| |||
April 13, 2012 Re: opHash?? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Fri, Apr 13, 2012 at 01:07:39PM -0500, Andrei Alexandrescu wrote: > On 4/13/12 12:15 PM, H. S. Teoh wrote: > >So this should be added to the errata, then? > > I'm on it. [...] Speaking of which, are you planning at some point to publish a second edition to TDPL? Maybe after the language settles down a bit more? Just curious. T -- Recently, our IT department hired a bug-fix engineer. He used to work for Volkswagen. | |||
April 13, 2012 Re: opHash?? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | On 4/13/12 1:16 PM, H. S. Teoh wrote: > On Fri, Apr 13, 2012 at 01:07:39PM -0500, Andrei Alexandrescu wrote: >> On 4/13/12 12:15 PM, H. S. Teoh wrote: >>> So this should be added to the errata, then? >> >> I'm on it. > [...] Added errata with credit. http://erdani.com/tdpl/errata > Speaking of which, are you planning at some point to publish a second > edition to TDPL? Maybe after the language settles down a bit more? Just > curious. New edition == major changes New printing == small changes, errata fixes I think we'll go with a new printing soon. Andrei | |||
April 14, 2012 Re: opHash?? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Friday, April 13, 2012 13:23:00 Andrei Alexandrescu wrote:
> I think we'll go with a new printing soon.
But then I'll have to buy another copy! ;)
Though trying to get your hands on the new printing once it comes out will probably be a bit hard for a while, because the odds of getting a copy of the first printing instead are likely to be fairly high at first.
- Jonathan M Davis
| |||
April 14, 2012 Re: opHash?? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On 4/13/12, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> wrote: > New printing == small changes, errata fixes Be sure to sneak in the lambda syntax as an errata fix. ;-) | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply