From: Jeronimo Pellegrini
Subject: When is it good to use #+implementation ?
Date: 
Message-ID: <fnqpgu$8jv$1@aioe.org>
I have checked that the Spartns library works with Poplog. However,
some tests fail because I use (make-hash-table :size 0), which
Poplog complains about[0].

I have already reported this on comp.lang.pop, but I was wondering
when it is considered OK to use #+ to include or exclude code for
different implementations.

All tests pass if I use
 (make-hash-table :size #+poplog (max 1 size) #-poplog 0)


I don't want to use :size 1 because this argument is also
used for other representations (liek compressed vectors), and
I don't want to allocate lots of vectors of size 1...

Thanks,
J.

[0] CLtL requires the argument to be a "non-negative integer", which
in my understanding includes zero. :-)

From: Thomas A. Russ
Subject: Re: When is it good to use #+implementation ?
Date: 
Message-ID: <ymiabmmx4vh.fsf@blackcat.isi.edu>
Jeronimo Pellegrini <···@aleph0.info> writes:

> I have checked that the Spartns library works with Poplog. However,
> some tests fail because I use (make-hash-table :size 0), which
> Poplog complains about[0].
> 
> I have already reported this on comp.lang.pop, but I was wondering
> when it is considered OK to use #+ to include or exclude code for
> different implementations.

Well, the conditionalization is designed to meet the need of doing
something different based on the feature being tested.  This is used to
make allowances for optional packages that might be installed, and to
test for various levels of conformance.

Occassionally it can also be used to work around bugs in particular
implementations.

So these are all valid reasons to use the construct.  So, go ahead and
use it to work around this bug.

> All tests pass if I use
>  (make-hash-table :size #+poplog (max 1 size) #-poplog 0)

Shouldn't the last one be "#-poplog size" instead of "#-poplog 0", to
give you the same results when size is non-zero?

Now, if you end up doing this alot, then you might want to introduce
your own helper function that reduces the number of places in the code
where there is such conditional constructs.  That makes maintenance
easier, and also protects you from inadvertently omitting it:

(defun make-sized-hash (size)
  (make-hash-table :size #+poplog (max 1 size) #-poplog size))

-- 
Thomas A. Russ,  USC/Information Sciences Institute
From: Jeronimo Pellegrini
Subject: Re: When is it good to use #+implementation ?
Date: 
Message-ID: <fnr8db$pv3$1@aioe.org>
On 2008-01-30, Thomas A. Russ <···@sevak.isi.edu> wrote:
> Well, the conditionalization is designed to meet the need of doing
> something different based on the feature being tested.  This is used to
> make allowances for optional packages that might be installed, and to
> test for various levels of conformance.
>
> Occassionally it can also be used to work around bugs in particular
> implementations.
>
> So these are all valid reasons to use the construct.  So, go ahead and
> use it to work around this bug.
>
>> All tests pass if I use
>>  (make-hash-table :size #+poplog (max 1 size) #-poplog 0)
>
> Shouldn't the last one be "#-poplog size" instead of "#-poplog 0", to
> give you the same results when size is non-zero?

Yes, you're right.
I have just released a new version with the proper fix.

> Now, if you end up doing this alot, then you might want to introduce
> your own helper function that reduces the number of places in the code
> where there is such conditional constructs.  That makes maintenance
> easier, and also protects you from inadvertently omitting it:

Yes, of course.
It seems that changing this Poplog behavior is not straightforward
(I asked on comp.lang.pop), so this one will have to stay... But
I don't plan to add many conditional reads.

Thanks for your response!
J.