[oleg@pobox.com: Minor quibbles on the latest draft] scgmille@xxxxxx (30 Jul 2003 22:24 UTC)
Re: [oleg@pobox.com: Minor quibbles on the latest draft] scgmille@xxxxxx (31 Jul 2003 03:20 UTC)
Re: [oleg@pobox.com: Minor quibbles on the latest draft] Jens Axel Søgaard (31 Jul 2003 07:34 UTC)
Re: [oleg@pobox.com: Minor quibbles on the latest draft] scgmille@xxxxxx (31 Jul 2003 13:02 UTC)
Re: [oleg@pobox.com: Minor quibbles on the latest draft] Jens Axel Søgaard (31 Jul 2003 13:55 UTC)
Re: [oleg@pobox.com: Minor quibbles on the latest draft] scgmille@xxxxxx (31 Jul 2003 15:34 UTC)

Re: [oleg@pobox.com: Minor quibbles on the latest draft] Jens Axel Søgaard 31 Jul 2003 07:32 UTC

xxxxxx@freenetproject.org wrote:

>>[forwarded on behalf of Oleg]
>>
>>advanced module system, I can import a particular dictionary
>>implementation (e.g., associative lists) with renaming
>>	make-alist => make-mydict
>>	alist-get  => mydict-get
>>etc. In my own code I would use the names make-mydict, mydict-get,
>>etc. exclusively. If at a later time I decide to use a different
>>dictionary implementation, I would only need to change the module
>>declaration statement.
>>
>>
>
>The problem with this approach is that it doesn't let you use two
>collections of different types by the same Scheme function.  For
>example:
>
>(define (myfunc a)
>  (set-contains? a 3))
>
>(myfunc (foo-set 1 2 3))
>(myfunc (bar-set 4 5 6))
>
For two reasons I prefer the naming make-mydict, mydict-get.
First, if I need a dictionary often it is unimportant how it is implemented,
second, I can change the implementation easyly as Oleg describes.

Whether the implementation is able to make automatic dispath on the
type of set in set-contains? is not /that/ important (to mee). My
intution says
that it's relatively seldom one needs to use more than one implementation
at a time (but it can happen).

If I need more than one implementation I do this:

  1. Make an extended set-"interface" containing myfunc.
  2. Implement myfunc  using foo and bar primitives
  3. Write the program like this

    (require (lib "alist-dict") (prefix foo))
    (require (lib "hash-dict") (prefix bar))

  (foo:myfunc (foo:set 1 2 3))
  (bar:myfunc (bar:set 4 5 6))

But since we dont't have a module system (yet?), we need to decide, what
to do. If a module system is not available the above would become a
nuisance.

I am not sure what The Pragmatic Thing is.

--
Jens Axel Søgaard