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: Thu, 12 Nov 2009 07:57:12 -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 felix):

 Replying to [comment:2 tonysidaway]:
 > Not sure how let-generic, etc, would  work.

 `let-generic` would bind a local variable to a newly created generic,
 `let[rec]-method` would during the extent of the body add a method for
 a specific generic.

 >
 > 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)))
 > }}}

 I don't see the improvement, here. The `make-class` looks clearer
 to me.

 > 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.

 I'm not sure I understand. Anything starting with `define` should not be
 evaluated for a result, that's something I find most un-Scheme-ly.

 >
 > 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.

 `define-method` is not a function, it's a definition, so adding the `!`
 would be non-idiomatic (IMHO).

 >
 > 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.

 I'll check out easyffi myself. It's quite a mess but crucial and rather
 complex. Thanks for the offer, though. I have very little time left for
 chicken hacking in the moment.

-- 
Ticket URL: <http://www.irp.oist.jp/trac/chicken/ticket/114#comment:3>
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]