MOO-cows Mailing List Archive

[Prev][Next][Index][Thread]

Re: [SERVER] LambdaMOO 1.8.x feature wishlist



> 
> > >    - differentiate between constant and mutable strings (String and 
> > >      StringBuffer in Java)
> > 
> > So, this is the request for the _addition_ of a mutable string data
> > type, right?
> 
> No no no no no.  The example I gave was misleading; I'm sorry for the 
> confusion.  What I meant on this suggestion (all items) were changes to 
> the VM to make it more efficient -- changes which (except for the time 
> and/or memory savings) should be invisible to MOO programmers.
> 
> The whole idea for this suggestion just came out of reading Meyer's More 
> Effective C++, Item 17, where he discusses implementing lazy evaluation 
> of strings, and lazy fetching of values from a database.  Both examples 
> led me to think of possible optimizations to the MOO VM, namely 
> distinguishing between variable and property reads and writes.
> I don't know enough about the MOO VM to know whether either of these 
> would be an improvement, but it seemed logical.
> 
> However, the example I gave was misleading.  I really meant altering how 
> strings (lists, property values, ...) are handled internally, to more 
> efficiently handle those data types.  I would definitely be opposed to 
> adding a new type to MOO (except for possibly binary like LPMOO has,
> or maybe other containers than lists, such as hashtables).
> 

I think the server already uses some form of lazy evaluation for strings
and lists. The server will allocate memory for a string only if the string
is modified. 

Example:

	a = "Some string";
	b = a;

	-> it doesn't copy the string "Some string" to b. It copies only
	   the reference to it and increase the reference count of it.
	   If the reference count of the string goes to 0, the memory
	   it occupies will be freed.

    But, 

	a = "Some string";
	b = a + " and more";

	-> it will allocate memory for "Some string and more" and var b
	   points it.

	-- Ahn

-----
Ahn, Jin-su    				email:	jsahn@ee.snu.ac.kr
School of Electrical Engineering	LambdaMOO: Deedlit(#103811)
Seoul National University, Korea


References:

Home | Subject Index | Thread Index