[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GOOPS and hash-tables - ie. <hash-table>
From: |
Daniel Hartwig |
Subject: |
Re: GOOPS and hash-tables - ie. <hash-table> |
Date: |
Sat, 23 Mar 2013 23:19:35 +0800 |
On 23 March 2013 23:15, Brent Pinkney <address@hidden> wrote:
> On 23/03/2013 16:09, Daniel Hartwig wrote:
>>
>> On 23 March 2013 19:18, Brent Pinkney <address@hidden> wrote:
>>>
>>> Hi,
>>>
>>> I desperately need to write a generic method that binds to a hash-table.
>>>
>>> I have noticed that native scheme types like pair, list, and vector are
>>> automagically recognised in GOOPS as <pair>, <list>, and <vector>.
>>> Even SRFI-19 dates are recognised as <date>.
>
>
>>> How did you spot those classes?
>
>
> I read the guile vm and module source code :)
>
>
>>
>>>
>>> How then to add similar goodness so that I can write:
>>>
>>> (define-method (enumerate! (o <hash-table>) env)
>>> ...
>>> )
>>>
>> A quick investigation using ‘class-of’ and the various constructors:
>>
>> scheme@(guile-user)> (class-of (make-hash-table))
>> $1 = #<<class> <hashtable> 9f96780>
>> scheme@(guile-user)> (use-modules (srfi srfi-69))
>> scheme@(guile-user)> (class-of (make-hash-table))
>> $2 = #<<class> <srfi-69:hash-table> a115000>
>>
>> Regards
>
> Ok, so you have confirmed that you can merrily make my enumerate! method ?
>
> I still fail to.
Which hash tables are you using?
scheme@(guile-user)> (define t (make-hash-table))
scheme@(guile-user)> (define-method (enumerate! (o <hashtable>) env)
(list o env))
scheme@(guile-user)> (enumerate! t #t)
$2 = (#<hash-table a2a0480 0/31> #t)