[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: hash-table-{to, from}-alist

From: Ted Zlatanov
Subject: Re: hash-table-{to, from}-alist
Date: Tue, 25 Nov 2008 11:33:34 -0600
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux)

On Tue, 25 Nov 2008 10:50:53 +0900 "Stephen J. Turnbull" <address@hidden> 

SJT> Ted Zlatanov writes:
>> The equality test is necessary if it was given originally (meaning,
>> if it's not 'eql).  I don't think we should ever omit it, even if
>> it's the default value, for readability.

SJT> I disagree.  But it's not incompatible as long as you don't make the
SJT> :test option to make-hash-table obligatory. ;-)

OK, I'll make :test optional.  Is size mandatory?  I ask since you put
it in your example, but you could have done so to illustrate

>> Would this work?
>> #s(hash-table size 2 test equal data (k1 v1) (k2 v2))

SJT> Not quite.  The data field in XEmacs is a plist, and the construct
SJT> above signals an error.

SJT> #s(hash-table size 2 test equal data (k1 v1 k2 v2))

I'm OK with that format and it seems pretty good, since (read) can (I
think) reuse the plist read syntax for the contents, so there's not much
work for a simple implementation.  Of course, an optimized
implementation might be necessary, but a working simple solution is
always a good first step.

>> Finally, the size is just a hint with make-hash-table; should the (read)
>> allow wrong sizes or throw an error?

SJT> XEmacs allows wrong sizes.  I think this makes sense, but it probably
SJT> isn't deliberate (the structure-reading mechanism validates field
SJT> values one at a time; I don't see a provision for cross-field
SJT> consistency checks).

SJT> #s(hash-table size 10 data (y y-value x x-value))
SJT> #<hash-table size 2/29 data (y y-value x x-value) 0x587cb2e2>

That's fine.  I'll just hard-code the size to 42 then. (kidding)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]