Re: [m-users.] A question about in-place updating...

Volker Wysk <[email protected]>
Newsgroups gmane.comp.lang.mercury.general
Message-ID <[email protected]>
Am Montag, dem 28.08.2023 um 13:02 +0100 schrieb Sean Charles
(emacstheviking):
> OK, I am now creating flight-path / animation / tweening system, that on
> every iteration of the game loop, will have to process every single
> instance of display objects and update their coordinates and set flags,
> alpha values etc etc. The number of such objects could become high, not
> punishingly high, for now I can't see it being more than a thousand, even
> with a primitive particle system generating explosions using texture maps
> it should not be massively high.
> 
> Currently I am just 'making it work', gut I am wondering longer term about
> what techniques might be open to me in Mercury given that it manages
> memory, does the garbage collection for me etc. such that I can minimise
> object allocation etc as instances are updated frame-by-frame.
> 
> 1) When I use list.reverse(), is it a shallow or deep copy of the
> original? I am assuming a shallow copy, with may be copy-on-write behind
> the scenes?
> 
> 2) If I have a list of say a thousand instances of a tween object, then as
> I process them, they will need to be updated as I save the current value
> in the instance along with a done flag, so either the values changes or
> the done flag changes, either way it means that a new instance will be
> created. Is there a way to make it so that Mercury can in-place update
> these instances rather than allocating new ones, so that it reduces memory
> thrashing and heap activity etc?
> 
> It's an interesting question for me to ponder at the moment! Given all
> that Mercury does, I am guessing that there are no ways to 'pin' a block
> of memory such that it can then be reused over and over, I have played
> around with bitmap but that's not really built for generic structures etc.
> I guess if it came to the crunch I could always re-code those things that
> need maximal performance in C but that kind of negates the reason I
> decided to write this game in Mercury.

What you describe seems to be a case for unique modes. See section 6 in the
Language Reference Manual.

Cheers,
Volker

_______________________________________________
users mailing list
[email protected]
https://lists.mercurylang.org/listinfo/users
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEE6QXGh82Ov3+2nrxp+K4ydFOsHoUFAmTsjsUACgkQ+K4ydFOs
HoXMtg/+K/IG0wCRLHwqHPxATyztepPYK+GxCL/JK6CbD6DjkUFa6W8k2Prk8v0m
2ynOe8mnTTCZFcTc7tMVkcL+E/HEOgFD9OW1jHRF2FPONGDlhQnHx5zogOyzgvoo
bnabj3sNA6jDqhQV55itroSUciP35jTJwxkb166WefU442j6UuL7LTQEpWaRmpBA
WWPBzvJ6U58Pmc/V7mIJi6qZuhj5mBNq9NSC7h8Ac/w6b9sz2KGVF9ZKjBd0rkKb
/WKk+Rs2OIi9R3gN9Sc9boUvPEZc9QoNRd3FT5LsFoTGVooTgtpckZDatuLw2jpX
DfTXMDDdgwu3ufTo6A7+e2REqOjEpAP4RRwIgfb+YRf9sXNg9YtL/lKwr3vePbpN
725SIybo1k3ZwlZx37EjWlnDTCgIBNbhy79Hl5drjmNLYcLMwO4oaCTqxys5/xgl
q3R/B6ut/XL6+zIc/nfdmbV+oq3tbHNd8eCkZDC0As9orRovmg6zYT6f6WNP8qTk
5ieBOld7ojfIW4uLKuPR79sugCHX3Ypldu4nscSi259Sx0Jl7eARSMBKfSDJ8V55
eASjC5jgreHrli1npIPzTxDgh7haKbk3PXGXRoxHZAvTx1Kcb+pHQ1OKrX/6NaHR
WHIc+kfH80oSD05Pcht47MRQe/Kl3f9tsQPkPeJhpLjyc3GjqaY=
=5Fgk
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.