Forward declaring the identity of an object

Red IO redio.development at gmail.com
Tue Jul 4 17:10:48 UTC 2023


I think the biggest problems would be
1. How do you mark a memory location as allocated (has identity aka memory
address)
but should still be treated as null which changes later without any notice.
It's like a reverse WeakReference
2. How would you represent it syntactically it's neither null nor a valid
object it's a in between state previously unknown.
3. There would be many changes in the language necessary to make this
feature work reliably and the use beyond niece things like circular
references in immutable datastructures are probably low.
4. This would also bring up many questions in which cases the memory
behaves like a object and in which case null. Like synchronization, null
checks, instanceof, etc.

It's likely not worth the complexity and the cost.

Great regards
RedIODev

On Tue, Jul 4, 2023, 15:47 David Alayachew <davidalayachew at gmail.com> wrote:

>
> Hello Amber Dev Team,
>
> I am starting this thread to start a spin off discussion from the
> "Question about circular references" thread above.
>
> In short, RedIODev mentioned something in passing that piqued my interest.
> The idea was the ability to reference a declared, but uninitialized
> variable (a reference), and allowing that reference to be passed to, let's
> say, another constructor, but not permitting derereference until the
> variable in question has fully been initialized.
>
> I wanted to get people's perspectives on this. Is this a good idea? A bad
> one? Is this too difficult to do? Not that difficult? Please let me know
> your thoughts.
>
> Thank you for your time and insight!
> David Alayachew
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20230704/aba583fb/attachment.htm>


More information about the amber-dev mailing list