Re: [Chicken-users] This may be a bug in chickens hash tables - or my bad

2015-12-17 Thread Kristian Lein-Mathisen
I may be completely misunderstanding something here, but don't you have to
use equal? and not eq? for record structures?

K.

On Wed, Dec 16, 2015 at 10:09 PM, Jörg F. Wittenberger <
joerg.wittenber...@softeyes.net> wrote:

> Ah, great to learn.
>
> a) You are right: Per SRFI-69 it is actually undefined.  Per chicken
> manual it returns the new value associated with key.
>
> As I've seen the latter (e.g. in the iup egg) actually being used, we
> might at least want to keep the behavior in chicken.
>
> b) But does not matter much.  I ran into this originally from
> hash-table-ref signaling a missing key.
>
> The attached, modified test case fails because it i) does not find the
> key object hence hash-table-fold'ing the tree to ii) find an association
> with the very key the lookup failed for before.
>
> My hypothesis (after lightly reading the srfi-69.scm source) that the
> eq?-hash procedure produces a different hash value for the lookup before
> and after the mutation.  Hence the lookup fails while walking the tree
> succeeds.
>
> /Jörg
>
> Am 16.12.2015 um 21:55 schrieb Peter Bex:
> > On Wed, Dec 16, 2015 at 09:47:31PM +0100, Jörg F. Wittenberger wrote:
> >> Hi,
> >>
> >> I always assumed that (make-hash-table eq?) would create a hash table
> >> usable with arbitrary chicken objects as keys.
> >>
> >> That is especially structures like objects created via define-record
> >> should be valid as keys.  That is: referencing the table using the very
> >> same object (comparing eq? to the key object of the insert operation)
> >> will succeed.
> >>
> >> However this fails for me.  At least after the key object was mutated
> >> between insert and reference time.
> >>
> >> See attached test case.
> >>
> >> Am I trying something illegal here?
> >>
> >> Thanks
> >>
> >> /Jörg
> >
> >> (use srfi-69)
> >>
> >> (define objtbl (make-hash-table eq?))
> >>
> >> (define (register! obj arg)
> >>   (hash-table-update! objtbl obj identity (lambda () (list obj arg
> >>
> >> (assert (eq? (register! 1 1) (register! 1 2)))
> >
> > I believe the return value of hash-table-update! is undefined.
> >
> > Cheers,
> > Peter
> >
>
>
> ___
> Chicken-users mailing list
> Chicken-users@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/chicken-users
>
>
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] This may be a bug in chickens hash tables - or my bad

2015-12-17 Thread Jörg F . Wittenberger
Am 17.12.2015 um 11:08 schrieb Kristian Lein-Mathisen:
> I may be completely misunderstanding something here, but don't you have to
> use equal? and not eq? for record structures?

AFAIK eq? should hold true when the two objects are the same.  Equal?
will compare all the slots.  (The latter is not defined to be so by
Scheme, but it's what chicken does (if I remember the manual correctly)).

> 
> K.
> 
> On Wed, Dec 16, 2015 at 10:09 PM, Jörg F. Wittenberger <
> joerg.wittenber...@softeyes.net> wrote:
> 
>> Ah, great to learn.
>>
>> a) You are right: Per SRFI-69 it is actually undefined.  Per chicken
>> manual it returns the new value associated with key.
>>
>> As I've seen the latter (e.g. in the iup egg) actually being used, we
>> might at least want to keep the behavior in chicken.
>>
>> b) But does not matter much.  I ran into this originally from
>> hash-table-ref signaling a missing key.
>>
>> The attached, modified test case fails because it i) does not find the
>> key object hence hash-table-fold'ing the tree to ii) find an association
>> with the very key the lookup failed for before.
>>
>> My hypothesis (after lightly reading the srfi-69.scm source) that the
>> eq?-hash procedure produces a different hash value for the lookup before
>> and after the mutation.  Hence the lookup fails while walking the tree
>> succeeds.
>>
>> /Jörg
>>
>> Am 16.12.2015 um 21:55 schrieb Peter Bex:
>>> On Wed, Dec 16, 2015 at 09:47:31PM +0100, Jörg F. Wittenberger wrote:
 Hi,

 I always assumed that (make-hash-table eq?) would create a hash table
 usable with arbitrary chicken objects as keys.

 That is especially structures like objects created via define-record
 should be valid as keys.  That is: referencing the table using the very
 same object (comparing eq? to the key object of the insert operation)
 will succeed.

 However this fails for me.  At least after the key object was mutated
 between insert and reference time.

 See attached test case.

 Am I trying something illegal here?

 Thanks

 /Jörg
>>>
 (use srfi-69)

 (define objtbl (make-hash-table eq?))

 (define (register! obj arg)
   (hash-table-update! objtbl obj identity (lambda () (list obj arg

 (assert (eq? (register! 1 1) (register! 1 2)))
>>>
>>> I believe the return value of hash-table-update! is undefined.
>>>
>>> Cheers,
>>> Peter
>>>
>>
>>
>> ___
>> Chicken-users mailing list
>> Chicken-users@nongnu.org
>> https://lists.nongnu.org/mailman/listinfo/chicken-users
>>
>>
> 


___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] New egg: hopefully

2015-12-17 Thread Jörg F . Wittenberger
Hi,

I just released the "hopefully" egg:  Composable transactional memory.

API inspired by Clojure's ref's and STMX.

Currently only some record types may be used with hopefully.  Further
versions should add other mutable types.

I'd love to get feedback on the API.

https://wiki.call-cc.org/eggref/4/hopefully

Release-info and source is at
http://askemos.org/chicken-eggs/index.html
(this may be added the egg index).

Best

/Jörg

BTW: STM is usually advertised because it frees the programmer from
getting locking sequences right.  However at least the "good", low level
API appears to here be marginally (~5-10%) faster than the equivalent
code using mutexs.

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Play with CHICKEN, Crepes-PHYS is out!

2015-12-17 Thread Kooda
Hi fellow schemers!

Crepes-party-hard-yolo-swag 2015 is now out!

You can check it out at http://kooda.itch.io/cphys2015

It’s a tiny game made in a few weeks using CHICKEN.

The main purpose of this project was to teach someone Lisp as well as
teaching me how to deploy CHICKEN projects on multiple platforms in
the form of self-contained binaries. The game is, for these reasons,
pretty narrow in terms of contents.

A post-mortem blog post should follow in the next few days, along with
the projects’s source-code. I will try to explain the different states
the project went in, and how I built the binaries.

Enjoy! :D

-- 
Envoyé depuis ma GameBoy.

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Play with CHICKEN, Crepes-PHYS is out!

2015-12-17 Thread Arthur Maciel
Congrats, Kooda! Really nice!  :)



On Thu, Dec 17, 2015 at 9:16 AM, Kooda  wrote:

> Hi fellow schemers!
>
> Crepes-party-hard-yolo-swag 2015 is now out!
>
> You can check it out at http://kooda.itch.io/cphys2015
>
> It’s a tiny game made in a few weeks using CHICKEN.
>
> The main purpose of this project was to teach someone Lisp as well as
> teaching me how to deploy CHICKEN projects on multiple platforms in
> the form of self-contained binaries. The game is, for these reasons,
> pretty narrow in terms of contents.
>
> A post-mortem blog post should follow in the next few days, along with
> the projects’s source-code. I will try to explain the different states
> the project went in, and how I built the binaries.
>
> Enjoy! :D
>
> --
> Envoyé depuis ma GameBoy.
>
> ___
> Chicken-users mailing list
> Chicken-users@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/chicken-users
>
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users