|
From: | Kjetil S. Matheussen |
Subject: | Re: the future of Guile |
Date: | Thu, 6 Dec 2007 15:52:58 +0100 (CET) |
"Marco Maggi":
3b. Death to structs! IMO they were "an attempt", but the resulting code is awful (sorry, but can you disagree?). Err.. but aren't structs the main part of how GOOPS is implemented?IMO Guile's structs do nothing that cannot be done better with a good old C struct wrapped by a SMOB.
I've mentioned this before, but In Snd there is a function to automatically create C structs. You have to free the underlying c object manually though, but adding a SMOB wrapper around shouldn't be that hard. Oh, and thats yet another "should" for HBGC: You don't need to mess with SMOBs to garbage collect C objects when using the HBGC. (load "eval-c.scm") (define-ec-struct <struct_name> <int> one <float-*> twos <char-*> three <SCM> scm) (define test (<struct_name> :one 1 :twos '(2) :three "three")) (-> test one) => 1 (-> test one 90) (-> test one) => 90 (-> test twos) => (2.0) (-> test twos '(4 5 6)) (-> test twos) => (4.0 5.0 6.0) (-> test three) => "three" (-> test three "four") (-> test three) => "four" (-> test scm) => #f (-> test scm (lambda (x) x)) ;; stored elsewhere too, so it won't be gc-ed. (-> test scm) => #<procedure #f ((x) x)> (-> test get-size) => 16 (-> test get-c-object) => ("A_POINTER" 147502592) (-> test destructor) ;;free it
[Prev in Thread] | Current Thread | [Next in Thread] |