Subject: Adding Built-ins

From: [email-masked] (Mike 'Hiccup' Wilson)
Date: Tue, 30 Nov 1993 23:08:23 -0800

Well,  I'm certainly not a C guru, but I do know how to fiddle a bit.  Recently
I've undertaken a project to start *yet another* MOO for the internet at large.
This particular project will deal a lot with moving of objects in a virtual
3-d Spherical space.  Several functions that our MOO programs will call
heavily we wish to put into the server to increase speed.  
I've been scanning the code, and have a *very* vague idea of what the
'Var'  datatype is  and can *almost*  understand it. (actually, I understand
the structure, just not how it is used within the program.)  For example,
from the MOO program I want to be able to issue this:

rec = rec2sph({bearing,elevation,range});

bearing elevation and range are all ints  that describe position to some
stationary point.  rec2sph should return {x-coord,y-coord,z-coord} each of
which is an int (thereby translating from spherical coordinates to rectangular
coordinates).  I know that the initial list is past as a Var datatype.  But,
how exactly do I refenence it?

arglist.v.list[1].v.num    just confused the hell out of me.  I hope I'm not
rambling incoherently, but the whole project depends on the ability to put
these routines in server.  Thank you for your time.

Mike Wilson  (Zaphod @ most MU*'s)

---

From: Pavel Curtis <[email-masked]>
Date: Wed, 1 Dec 1993 11:50:13 -0800

> Date:	Tue, 30 Nov 1993 23:08:23 -0800
> From:	[email-masked] (Mike 'Hiccup' Wilson)
> 
> For example, from the MOO program I want to be able to issue this:
> 
> which is an int (thereby translating from spherical coordinates to
> rectangular coordinates).  I know that the initial list is passed as a Var
> datatype.  But, how exactly do I refenence it?
> 
> arglist.v.list[1].v.num    just confused the hell out of me.

First, `arglist' is, as the name might suggest, a *list* of the arguments.
Thus, in MOO syntax, `arglist' is

	{{bearing, elevation, range}}

This is probably the wrong thing, from a design point of view.  You should
probably have the programmer type

	rec2sph(bearing, elevation, range)

without the extra layer of list.

The representation of lists in the server is straightforward, given this
understanding.  The only obscure piece is that the length of the list is stored
in its zero'th element.  Suppose that `x' is a `Var' variable holding a MOO
list of length 3.  Then

	x.type == TYPE_LIST
	x.v.list[0].type = TYPE_NUM
	x.v.list[0].v.num = 3

and the n'th element of the list is in

	x.v.list[n]

Does that make it clearer?

	Pavel