<html><head><meta http-equiv="content-type" content="text/html; charset=us-ascii"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div>OK, so, I've started on the journey again... here's the smallest little example I tried, just to try to even create something that could later be used as a destructively updated instance,</div><div><br></div><div><font face="Courier New"> 104 :- type blob ---> blob(int).</font></div><div><font face="Courier New"> 105 </font></div><div><font face="Courier New"><b> 106 :- func mk_blob1(int::in) = (blob::uo) is det.</b></font></div><div><font face="Courier New"> 107 mk_blob1(X) = blob(X).</font></div><div><font face="Courier New"> 108 </font></div><div><font face="Courier New"><b> 109 :- pred blob1_info(blob::in, io::di, io::uo) is det.</b></font></div><div><font face="Courier New"> 110 blob1_info(B, !IO) :-</font></div><div><font face="Courier New"> 111 B = blob(Val),</font></div><div><font face="Courier New"> 112 io.format("blob: %i\n", [i(Val)], !IO).</font></div><div><font face="Courier New"> 113 </font></div><div><font face="Courier New"><b> 114 :- func mk_blob2 = (blob::uo) is det.</b></font></div><div><font face="Courier New"> 115 mk_blob2 = blob(42).</font></div><div><font face="Courier New"> 116 </font></div><div><font face="Courier New"><b> 117 :- pred blob2_info(blob::ui, io::di, io::uo) is det.</b></font></div><div><font face="Courier New"> 118 blob2_info(B, !IO) :-</font></div><div><font face="Courier New"> 119 B = blob(Val),</font></div><div><font face="Courier New"> 120 io.format("blob: %i\n", [i(Val)], !IO).</font></div><div><br></div><div>the compiler output is:</div><div><br></div><div><div><font face="Courier New">g1.m:107: In clause for `mk_blob1(in) = uo':</font></div><div><font face="Courier New">g1.m:107: mode error: argument 2 did not get sufficiently instantiated.</font></div><div><font face="Courier New">g1.m:107: Final instantiatedness of `HeadVar__2' was `unique(blob(ground))',</font></div><div><font face="Courier New">g1.m:107: expected final instantiatedness was `unique'.</font></div><div><br></div><div><font face="Courier New">g1.m:120: In clause for `blob2_info(ui, di, uo)':</font></div><div><font face="Courier New">g1.m:120: mode error: argument 1 did not get sufficiently instantiated.</font></div><div><font face="Courier New">g1.m:120: Final instantiatedness of `B' was `unique(blob(ground))',</font></div><div><font face="Courier New">g1.m:120: expected final instantiatedness was `unique'.</font></div><div><br></div></div><div>In the manual is says:</div><div><br></div><div>"Mode uo is used to create a unique value."</div><div>"Mode ui is used to inspect a unique value without losing its uniqueness."</div><div>"Mode di is used to deallocate or reuse the memory occupied by a value that will not be used. "</div><div><br></div><div>I have so far interpreted this, obviously incorrectly, that wanting to create a new 'blob' meant that the output would be 'uo' but it seems I have done something to upset the compiler regarding HeadVar__2, presumably the returned value given the error message. The second version works presumably because the number 42 is a ground value, but right now, I have no idea how I would pass in a bunch of values, mangle them and return a new instance of something that I would later want to use destructively. Learning time...</div><div><br></div><div>Some explanation of what I have done wrong would help as, once again, I find myself reading the section 6 content and it mostly going over my head. Ultimately, I want to be able to create a list of things, then in-place modify those things, and ultimately junk them on program exits. That's all. My problem i guess is not fully understanding what the compiler means by 'unique' and 'dead'.</div><div><br></div><div>Thanks,</div><div>Sean.</div><div><br><blockquote type="cite"><div>On 28 Aug 2023, at 13:10, Volker Wysk <post@volker-wysk.de> wrote:</div><br class="Apple-interchange-newline"><div><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">Am Montag, dem 28.08.2023 um 13:02 +0100 schrieb Sean Charles</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">(emacstheviking):</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><blockquote type="cite" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">OK, I am now creating flight-path / animation / tweening system, that on<br>every iteration of the game loop, will have to process every single<br>instance of display objects and update their coordinates and set flags,<br>alpha values etc etc. The number of such objects could become high, not<br>punishingly high, for now I can't see it being more than a thousand, even<br>with a primitive particle system generating explosions using texture maps<br>it should not be massively high.<br><br>Currently I am just 'making it work', gut I am wondering longer term about<br>what techniques might be open to me in Mercury given that it manages<br>memory, does the garbage collection for me etc. such that I can minimise<br>object allocation etc as instances are updated frame-by-frame.<br><br>1) When I use list.reverse(), is it a shallow or deep copy of the<br>original? I am assuming a shallow copy, with may be copy-on-write behind<br>the scenes?<br><br>2) If I have a list of say a thousand instances of a tween object, then as<br>I process them, they will need to be updated as I save the current value<br>in the instance along with a done flag, so either the values changes or<br>the done flag changes, either way it means that a new instance will be<br>created. Is there a way to make it so that Mercury can in-place update<br>these instances rather than allocating new ones, so that it reduces memory<br>thrashing and heap activity etc?<br><br>It's an interesting question for me to ponder at the moment! Given all<br>that Mercury does, I am guessing that there are no ways to 'pin' a block<br>of memory such that it can then be reused over and over, I have played<br>around with bitmap but that's not really built for generic structures etc.<br>I guess if it came to the crunch I could always re-code those things that<br>need maximal performance in C but that kind of negates the reason I<br>decided to write this game in Mercury.<br></blockquote><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">What you describe seems to be a case for unique modes. See section 6 in the</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">Language Reference Manual.</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">Cheers,</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">Volker</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">_______________________________________________</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">users mailing list</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><a href="mailto:users@lists.mercurylang.org" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">users@lists.mercurylang.org</a><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><a href="https://lists.mercurylang.org/listinfo/users" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">https://lists.mercurylang.org/listinfo/users</a></div></blockquote></div><br></body></html>