<div dir="ltr">One thing we discussed at some length in VisualWorks is a polymorphic solution for empty slots and &quot;expired&quot; weak references. &nbsp;In Squeak a WeakArray&#39;s references to reclaimed objects are replaced with nil. In VisualWorks they are replaced with 0. &nbsp;Replacing with 0 allows a weak collection to identify the references just dropped. &nbsp;A typical weak collection will be finalized and in its finalization code will scan for 0&#39;s and process corresponding entries for those indices held off to the side (e.g. finalizable copies). &nbsp;As each 0 is encountered it will be replaced with nil.<div>
<br></div><div>THis obviously poses a problem for e.g. hashed collections as these can either no longer contain 0 or must be made thread-safe and have the finlaization code effectively atomically set all 0&#39;s to nil. &nbsp;But the thread-safe solution works only for uses less than the finalization process&#39;s priority. &nbsp;The sketch solution we came up with is to introduce two singletons, unbound and tombstone which both answer true to isUnbound and all other objects answer false. &nbsp;tombstone answers true to isTombstone and all other objects answer false. Expired weak references are overwritten with tombstone and hashed collections check for an unbound slot with isUnbound and an expired reference with isTombstone. &nbsp;This&nbsp;has support code in the VM but has yet to be implemented&nbsp;in the image. &nbsp;The VM&#39;s tombstone remains set to 0.<br>
<br></div><div>Hopefully this bites fewer users than nil as an unbound marker but there will still be system contexts where unbound is a value that needs to be dealt with (SystemTracer et al). &nbsp;So the catch is that one has introduced more complexity with its own attendant problems.</div>
<div><br></div><div><br></div><div><br><div class="gmail_quote">On Sun, Aug 10, 2008 at 8:16 AM, Louis LaBrunda <span dir="ltr">&lt;<a href="mailto:Lou@keystone-software.com">Lou@keystone-software.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi Igor,<br>
<br>
How about creating a new class called #MetaUndefinedObject or #MetaNil. &nbsp;Stick<br>
it between #Object and #UndefinedObject. &nbsp;By definition it would never be used<br>
as an object, it would only be used as a filler for collections like #Set,<br>
indicating that no &quot;real&quot; object is present.<br>
<br>
This would allow nil to be used in sets and elsewhere and allow it to be placed<br>
in a set from a database row where a column is null without changing other code.<br>
<br>
This would not solve the recursive collection problem but that could be solved<br>
at it source.<br>
<br>
Lou<br>
-----------------------------------------------------------<br>
<font color="#888888">Louis LaBrunda<br>
Keystone Software Corp.<br>
SkypeMe callto://PhotonDemon<br>
mailto:<a href="mailto:Lou@Keystone-Software.com">Lou@Keystone-Software.com</a> <a href="http://www.Keystone-Software.com" target="_blank">http://www.Keystone-Software.com</a><br>
<br>
<br>
</font></blockquote></div><br></div></div>