Uses 1059K of libraries. Click here for Pure Java version (625L/4K).
!7 // Makes the Concept.Ref object unnecessary by directly // storing the reference in a field. // We can probably get rid of the refs field in the same go. // Of course, backRefs are still needed. // TODO: We need backRefs to be able to store concepts also // (by changing its type to L). // Or we add another field directBackRefs. sbool isConceptRefValid(Concept src, Concept dest) { ret src != null && dest != null && src._concepts != null && src._concepts == dest._concepts; } svoid indexConceptRef(Concept src, Concept dest) { if (isConceptRefValid(src, dest)) { // dest._addBackRef(src); change(); } } svoid unindexConceptRef(Concept src, Concept dest) {} sO conceptRefMutex(Concept c) { ret or(c._concepts, dummyMutex()); } concept Thing { Thing ref_ptr; // setter selfType ref(Thing dest) { synchronized(conceptRefMutex(this)) { if (ref_ptr != dest) { unindexConceptRef(this, ref_ptr); ref_ptr = dest; indexConceptRef(this, dest); } } this; } // getter. we could get rid of this by making the field // publicly accessible, but then we run the slight chance // of setting it without the setter inadvertently. Thing ref() { ret ref_ptr; } } cprint {}
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1031144 |
Snippet name: | Weightless Concept Refs Spike [dev.] |
Eternal ID of this version: | #1031144/5 |
Text MD5: | b6ad928836ac2767cab8eae8ba53f2b1 |
Transpilation MD5: | 8970b7adedc1065d5ce1a5695e984995 |
Author: | stefan |
Category: | javax / concepts |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-05-12 23:26:19 |
Source code size: | 1299 bytes / 50 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 170 / 271 |
Version history: | 4 change(s) |
Referenced in: | -