Re: [Chicken-users] Review my Caesar Cipher?

2014-03-13 Thread Daniel Carrera
On 12 March 2014 17:16, Alex Shinn  wrote:
>
> Then change your cond-expand to:
>
> (cond-expand
>  ((or chicken gauche)  ; compatibility
>   (use srfi-13))
>  (else ; R7RS
>   (import (scheme base) (scheme write
>
>
That works. Thanks!

I have updated the page on Rosetta Code. It now works correctly on Chicken,
Gauche, Chibi and I also added Kawa. Thanks for the explanation.

Cheers,
Daniel.
-- 
When an engineer says that something can't be done, it's a code phrase that
means it's not fun to do.
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Question about gc-roots

2014-03-13 Thread pluijzer .
I am assigning non-immediate objects to foreign void pointers. To
prevent them from moving during garbage collection I turn the pointer
into a gc-root.

This works like I expect it would work, with one exception:

It seems that the finalizers of the objects assigned to the objects
inside the gc-root get fired prematurely.

I think I'm a little difficult to follow, I'll give an example:


#>
void* ptr;
<#

(define init-root
 (foreign-lambda* void ((scheme-object obj)) "
ptr = CHICKEN_new_gc_root();
CHICKEN_gc_root_set(ptr, obj);"))

(define root-ref
  (foreign-lambda* scheme-object () "
C_return(CHICKEN_gc_root_ref(ptr));"))

(define (make-some-string)
  (set-finalizer! "hello" (lambda (s) (print s ", just got freed."

(define-record metadata
  data)

(init-root (make-metadata (make-some-string)))

; prints "hello"
(print (metadata-data (root-ref)))

; will fire finalizer printing "hello, just got freed."
; I didn't expect this because there is still a refrence to the object
inside the root.
(gc #t)

; prints "hello", object seems to still be around.
(print (metadata-data (root-ref)))
---

Maybe I don't understand gc-roots and use them wrongly or for the
wrong purpose. If so, would somebody kindly explain.

Thanks in advance,
Pluijzer

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