Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2001:
[Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability a
Home

[Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability a

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: gregor@xxxxxxxxxxxxx
Cc: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development]
From: Daniel L Speyer <dspeyer@xxxxxxxxxxx>
Date: Mon, 3 Dec 2001 10:56:07 -0500 (EST)

I wrote in lisp because there's some list-handling involved, and
anonymous functions are helpful.  Here's the almost-as-nice javascript:

function healer_turn_done (me){
        var i,l;
        l=getUnitList(getTile(me));
        for(i=0;i<l.length;i++)
                l[i].health=l[i].maxHealth;
}
healer=new unit();
healer.attack=0;
healer.defend=1;
healer.move=2;
healer.ignoreZoc=true;
healer.maxHealth=10;
healer.turnDoneHook=healer_turn_done;
createUnit(healer);


This is slightly longer, and IMHO, slightly uglier, but it's still quite
doable.  I think python would be nicer than this (IIRC, it has forall
(essentially mapcar) and lambda), and other lightweight languages are also
possible.

--Daniel Speyer
"May the /src be with you, always"


On Mon, 3 Dec 2001, Gregor Zeitlinger wrote:

> On Mon, 3 Dec 2001, Daniel L Speyer wrote:
> > (setq healer (make-object 'attack 0 
> >                           'defend 1 
> >                       'move 2 
> >                       'ignore-zoc t 
> >                       'max-health 10))
> > (setf (get-object healer 'done-hook)
> >       #'(lambda (me)
> >       (mapcar 
> >        #'(lambda (x) (setf (get-object x 'health) 
> >                            (get-object x 'max-health)))
> >        (get-unit-list (get-tile me)))))
> > (create-unit healer)
> I'm impressed. It's somewhat obscure for an OO programmer like me but
> since it is an easy example. How would that look in a Java scripting
> language? Not as pretty probably.
> But - beauty of syntax istn't the only argument.
> 
> -- 
> Gregor Zeitlinger      
> gregor@xxxxxxxxxxxxx
> 
> 
> 



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