[Jprogramming] Non-mutable arrays
'Pascal Jasmin' via Programming
programming at jsoftware.com
Sat Oct 1 13:40:00 UTC 2016
In place operations apply to non named or name-reused data or data that can be "pre-copied", afaiu.
> specifically array
classes structured in such a way that you can create a copy which reuses
the old unchanged content and then change the contents of this copy
Forcing immutable only arrays is not an option for this language if it is to remain compatible with itself, though afaiu, there are optimizations in
array&i.
array&(-:"n)
e.&array
Henry once talked about an Optimization O. conjunction that provided hints as to whether data was presorted/unique. I'm unsure that immutable has to be a special optimization hint, because operations, even }, have an (locigcally) immutable (return new array/result) behaviour, and what Henry is working on is conditions where optimizations can reuse the memory.
----- Original Message -----
From: Erling Hellenäs <erling at erlinghellenas.se>
To: programming at jsoftware.com
Sent: Saturday, October 1, 2016 6:06 AM
Subject: [Jprogramming] Non-mutable arrays
Hi all !
As I am sure most people here know, functional programmers prefer to use
non-mutable data, very often lists. There are also non-mutable arrays.
Now, in J development, we talk about operations in place, which seems to
go in opposite direction, from the mainly non-mutable arrays we have to
mutable arrays. Is there an analysis which shows that this is the right
way to go?
Another option would be to use non-mutable arrays, specifically array
classes structured in such a way that you can create a copy which reuses
the old unchanged content and then change the contents of this copy.
Usually you can create a mutable array and define its content, then make
it non-mutable before you return it.
I tried non-mutable array in F#, and they seem slow compared to ordinary
arrays, but on some of them a copy operation was very fast. I am not
sure of how using such arrays would affect the performance of our systems.
Cheers,
Erling Hellenäs
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list