Subject: object numbers

From: Tim Keanini <[email-masked]>
Date: Wed, 17 Nov 1993 07:11:35 -0800

I have looked in the manual and this issue of how objects get their 
numbers is really unclear.
For example:

On page 4 of the Programmers manual, it says that object numbers that are 
created, never get reused even if they are recycled.  This is not true 
with 1.7.5 version of Lambda?  It seems that objects that are recycled 
get reused and sometimes that is really tricky with exits where the .dest 
is pointing now to something other than a object of type room.

How can you create a object and get a specific number?
Lets say that max_object() was #76, could you specify the creation of 
object number #100?

Thanks for all the advice in advance.

+====================================================================+
|    Tim Keanini    |"Art is not a mirror. Art is a Hammer" -MediaLab|
|aka blast          |           Come and visit us at bayMOO          |
|                   |                mud.crl.com 8888                |
|                   |            The only rule is RESPECT!           |
|                   |================================================+
|for more info on bayMOO...             <[email-masked]>            |
|  email [email-masked]                  <[email-masked]>              |
+====================================================================+

---

From: Greg Hudson <[email-masked]>
Date: Thu, 18 Nov 1993 13:47:24 -0800

> numbers is really unclear.

I'd ordinarily defer and let someone more experienced answer this
question in more detail, but I feel like preaching on this issue a
bit.  Someone please correct me if I'm wrong about anything.

When you ask the server to create an object, it assigns it a new
object number which has never been used before.

At some people, people got tired of seeing really large object numbers
on Lambda, and they wanted object numbers to be recycled.  This was
implemented in-db.  If I want, I can set a flag on an object such that
its number won't be recycled, but usually, when I discard an object,
it gets stripped of most of its data and sits around so that it can be
reused when someone else asks to create an object.

I don't know the names of the verbs involved here; I suspect a look at
me:@recycle will be enough to see how it works.

In my opinion, object number recycling is a really bad idea.  As you
mentioned, confusing things can happen if there are dangling
references to an old object and its number is recycled.  While it is
indeed easier to remember smaller object numbers, you really shouldn't
have to remember them at all, just like you shouldn't have to remember
pointer values in a C program.  Ideally, the core database should
provide some symbolic means of access to objects for all operations.
I don't have solutions in mind for every operation which people
normally use object numbers for currently, but I'm sure they're not
too hard to dream up.

--GBH

---

From: [email-masked]
Date: Thu, 18 Nov 1993 13:17:55 -0800

> is pointing now to something other than a object of type room.

There is a difference between @recycle and the builtin recycle(). When
you recycle() an object it is gone forever. @recycle (on some Moos)
does not recycle() the object, instead it just clears the verbs and
properties and then puts it in a pool for @create to reuse.

> How can you create a object and get a specific number?

Well, you can keep creating until you get a number, or you can manually
extract an object from the recycling bin and use it.

> Lets say that max_object() was #76, could you specify the creation of 

You need to create all the objects from #77 to #99, and toss them in
the recycling bin. :)

> Thanks for all the advice in advance.

Check out $recycler and the code and properties therein.

--JRP [Shirgall@many many moos]

---

From: Pavel Curtis <[email-masked]>
Date: Thu, 18 Nov 1993 17:35:52 -0800

> Date:	Wed, 17 Nov 1993 07:11:35 -0800
> From:	Tim Keanini <[email-masked]>
> 

Remember that the Programmers Manual is only discussing the behavior of the
language and built-in functions themselves, not any code that might be layered
on top of them in the database.  In recent versions of the LambdaCore DB, all
of the standard building commands (@create, @dig, etc.) use $recycler:_create()
instead of the built-in function create().  Symmetrically, the @recycle command
uses $recycler:_recycle() instead of recycle().  $recycler maintains a list of
pseudo-recycled objects and hands them out as a kind of pseudo-creation.

> Lets say that max_object() was #76, could you specify the creation of 

There isn't any simple and direct way to do this.  The simplest answer for the
specific example you gave is to create (and, perhaps, recycle) 23 objects and
then create one more.  That last one will get number #100.  If you wanted to
create something with a number that's no longer in use but is less than
max_object(), then you'd have to use some combination of renumber() and/or
reset_max_object() along with create() to do it.

	Pavel

---

From: Judy Anderson <[email-masked]>
Date: Thu, 18 Nov 1993 21:23:41 -0800

Greg is right: object numbers are evil, and one shouldn't have to use
them.  But the fact of the matter is that you *do* have to use them,
and it's already a pain.  With the creation/recycle rate at LambdaMOO
I am certain we would be over 200,000 by now, possibly even higher.
Object number reuse is indeed evil.  I fully understand this, which is
why new players always get fresh new numbers.

Ther are two ways for the current reuse system to work.  The "old
way", present in the LambdaCore.db, is that each player has a
property, .recreate_enabled, which if set to 1, enables reuse of
objects through the $recycler.  If set to 0, objects are actually
destroyed, and creation gets you fresh numbers.  The "new way" uses
the builder-options package, you type @builder-option +bi_create to
disable object number re-use (bi stands for built-in).  This will be
released with the next LambdaCore.

As to the question of controlling what number you get:  Obviously in
the reuse case, since the objects are really still there, you can do
anything you want (in fact $recycler has a request number from this
command to facilitate this).  However with the builtin create
primitive, you always get the next higher number after max_object();
you can't pick.  If you have !valid numbers in the middle of your db
(from having used recycle() before), you can "get back" those numbers
by doing:

foo = create(#1);
renumber(foo);
reset_max_object();

You get the *lowest* invalid number back.  Again, you can't pick this
number.  So if you've recycle()d 500 through 666 and you want 666
back, you have to do the renumber trick on 167 objects...

Judy Anderson yclept yduJ   [email-masked]  'yduJ' rhymes with 'fudge'
    [ LambdaMOO is lambda.parc.xerox.com 8888 / 13.2.116.36 8888 ]
       Join the League for Programming Freedom, [email-masked]