[DGD] LWO

Littlefield, Tyler tyler at tysdomain.com
Sun Aug 9 01:38:53 CEST 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This is cool, thanks. I got what I was trying for working today.
Are there many different systems open-sourced in LPC? I'd like to see
how things are done, most especially with DGD.

Thanks,
On 8/8/2015 10:19 AM, bart at wotf.org wrote:
> An example LWO can be found at:
> 
> http://wotf.org/downloads/lpc/kvset.c
> 
> It should work on gurbalib directly (and with little or no
> modification on about every other lib).
> 
> It implements a variation on the mapping type that adds support for
> &, | and - operators.
> 
> Bart
> 
> On Sat, 8 Aug 2015 12:05:05 +0200, bart wrote
>> Creating an LWO is easy:
>> 
>> object src; object lwo;
>> 
>> src = find_object( "/path/to/some/object" ); lwo = new_object(
>> src );
>> 
>> lwo will be the lightweight object, src is a blueprint object
>> used as a template for the lwo.
>> 
>> Note that an object does not have to do anything special to be 
>> usable as lwo, but there are some differences between a clone of
>> a blueprint object and an lwo:
>> 
>> Very important: lightweight objects do not get destructed
>> explicitly, they simply are forgotten when nothing references
>> them anymore. This means (very important if you are trying to do
>> any kind of object management or data storage on destruct) there
>> will be NO calls to the lwo informing it that it is going to be
>> destructed. This is a simple fact and not something that you can
>> code your way around, it is a consequence of the nature of LWOs.
>> 
>> LWOs can *NOT* have call_outs. Again, this is a consequence of
>> the nature of LWOs. Do not use LWOs for code that must use
>> call_outs or move the call_outs to some other bit of code not in
>> an LWO.
>> 
>> LWOs are kept in the storage space of the object that created
>> them (did the call to new_object()). ALL the things that apply to
>> arrays and mappings that are passed by reference from one object
>> to another also apply to LWOs. This means they will only be
>> shared until the end of the execution round, after which a copy
>> will be made and both objects involved will end up having their
>> own copy of the LWO.  For example, you might want to keep track
>> of some centralized counter for something. You decide to stick
>> this in some object, and let everything that needs this counter
>> call the object. So far so good, and this works with blueprints
>> (as you can simply use find_obect() and are guaranteed to end up
>> at that blueprint) or clones (you have to pass the object
>> reference to code that needs it). Doing this with an LWO however
>> may or may not work depending on exactly how you implement this:
>> - pass lwo reference to other object, which uses it to reference
>> the counter and then forgets it, all in the same execution round:
>> this works - pass lwo reference to another object which stores it
>> and then later on (as the result of a call_out or other user
>> action) tries to use it: this will not work as expected as the
>> LWO is no longer the one that was stored originally, it is a copy
>> of it.
>> 
>> Also important, LWOs support features that regular clones do not,
>> especially operator overloading (see the git commit log for dgd,
>> look for the keyword operator).
>> 
>> Anyway, there are things for which LWOs are an absolutely
>> brilliant solution, things like building advanced data types (for
>> example mappings that can contain a lot more then 16384 key/value
>> pairs), but also things for which they are a very cumbersome
>> solution that is best be avoided.
>> 
>> So.. creating them is easy, making good use of them however
>> requires some more careful thought really, they are not 'just an
>> alternative for clones', rather, they are something totally
>> different then clones, and generally things that need clones
>> cannot easily be done with LWOs and the other way around.
>> 
>> Bart.
>> 
>> On Sat, 08 Aug 2015 03:33:39 -0400, Littlefield, Tyler wrote
> Hello all: I've been looking for examples. Is there a syntax for
> creating an LWO? Any help appreciated. Thanks, - -- Take care, Ty
> twitter: @sorressean web:http://tysdomain.com pubkey:
> http://tysdomain.com/files/pubkey.asc

>>> ____________________________________________ 
>>> https://mail.dworkin.nl/mailman/listinfo/dgd
>> 
>> -- http://www.flickr.com/photos/mrobjective/ 
>> http://www.om-d.org/
>> 
>> ____________________________________________ 
>> https://mail.dworkin.nl/mailman/listinfo/dgd
> 
> 
> -- http://www.flickr.com/photos/mrobjective/ http://www.om-d.org/
> 
> ____________________________________________ 
> https://mail.dworkin.nl/mailman/listinfo/dgd
> 

- -- 
Take care,
Ty
twitter: @sorressean
web:http://tysdomain.com
pubkey: http://tysdomain.com/files/pubkey.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBAgAGBQJVxpMNAAoJEAdP60+BYxejo5wH/iatnZXyhqU2+p0WbZBnXJWI
QxOTC35kNHGfQJjd1B/+DZ+WGTeG3lrgJadDHwOu/kPs3fEGZsHvioT0jDxQomnB
F5aNw3/QT0XCIt0xQ4gjRFbBQ18Q9Ffd22RFriIh9y3EXBSKXwaazx5YD172CRgH
/jhyxfVIgtjRzs6bgtpkdyUAkivwU7dH3Xkf9AcPf71zHwD36vmJyvQEDhvt+zjU
7W+KG5KaO03/pPEqk+YXf4M+etMXcnMVlpZqgYkcqQNmKW2KWa8T5AFkKG/A5Bzj
abUmxPOT0PV7EIA5HmTEmC8m/okqFkAz4jm6VzVPchOy5a0ZX9SL/ynbyIipsCc=
=iaK9
-----END PGP SIGNATURE-----



More information about the DGD mailing list