[Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability a
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
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
>
>
>
- [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development], (continued)
- [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development], Reinier Post, 2001/12/04
- [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development], Andrew Sutton, 2001/12/04
- [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development], Reinier Post, 2001/12/05
- [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development], Andrew Sutton, 2001/12/05
- [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development], Reinier Post, 2001/12/05
- [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development], Ross W. Wetmore, 2001/12/05
- [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development], Reinier Post, 2001/12/08
- [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development], Daniel L Speyer, 2001/12/08
- [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development], Andrew Sutton, 2001/12/09
- [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development], Gregor Zeitlinger, 2001/12/03
- [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development],
Daniel L Speyer <=
- [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development], Reinier Post, 2001/12/04
- [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development], Raimar Falke, 2001/12/03
- [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development], Daniel L Speyer, 2001/12/03
- [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development], Andrew Sutton, 2001/12/03
- [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development], Daniel L Speyer, 2001/12/03
- [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development], Reinier Post, 2001/12/04
- [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development], Andrew Sutton, 2001/12/04
- [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development], Reinier Post, 2001/12/05
- [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development], Ross W. Wetmore, 2001/12/05
- [Freeciv-Dev] Re: Development Strategies [Was Documentation, Usability and Development], Raimar Falke, 2001/12/03
|
|