chicken-janitors
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-janitors] Re: #114: Improvements to tinyclos


From: Chicken Trac
Subject: [Chicken-janitors] Re: #114: Improvements to tinyclos
Date: Wed, 11 Nov 2009 15:06:58 -0000

#114: Improvements to tinyclos
---------------------------+------------------------------------------------
 Reporter:  tonysidaway    |       Owner:  tonysidaway
     Type:  task           |      Status:  new        
 Priority:  major          |   Milestone:             
Component:  extensions     |     Version:  4.2.x      
 Keywords:  tinyclos clos  |  
---------------------------+------------------------------------------------

Comment(by tonysidaway):

 Not sure how let-generic, etc, would  work.

 You can see what my coding style is like in the file tests/run.scm  In
 testing it's very useful to be able to create and destroy classes and
 methods on the fly, and I'm using a new define-class* macro that can be
 used like this:

 {{{
   (let* ((<pos> (define-class* () (x y)))
         (<circle> (define-class* (<pos>) (radius)))
         (p (make <pos>))
         (c (make <circle>)))
    ...)
 }}}

 It's just syntactically a little more natural than

 {{{
  (let* ((<pos> (make-class '() '(x y)))
         (<circle> (make-class (list <pos>) '(radius)))
 }}}

 You lose the class name because I don't want to force the programmer to
 type the name of his symbol twice.  Presumably if he becomes attached to
 the class he can set its class name later.

 There is already a (make-generic [NAME]) so that's not an issue.  It works
 well with Scheme.

 define-method doesn't actually create a new Scheme binding so I do
 something like

 {{{
  (let* ((gen (make-generic))
         (ignore (define-method (gen (b <boolean>)) (if b 1 0))))
  ...)
 }}}

 It looks awkward. You could shunt the define-method into the body of a
 block but then you're off starting a new block as soon as you want to
 create objects and manipulate them using your new generic.

 define-method actually works by mutating the generic, so by Scheme
 conventions it could be called "define-method!" or "add-method-to-
 generic!" instead--not that I'm suggesting a change of name at this stage.
 Well not seriously.

 If you don't have time to look at easyffi I may do so myself.  swig is a
 bit of a monster so for small-scale wraps easyffi is preferable.  I didn't
 even know it had any object support features.

-- 
Ticket URL: <http://www.irp.oist.jp/trac/chicken/ticket/114#comment:2>
Chicken Scheme <http://www.call-with-current-continuation.org/>
Chicken Scheme is a compiler for the Scheme programming language.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]