Can’t save WS while file mapped

APL-related discussions - a stream of APL consciousness.
Not sure where to start a discussion ? Here's the place to be
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !

Can’t save WS while file mapped

Postby jmosk on Sat Sep 23, 2017 3:05 pm

I am using the ⌷MAP function to read a binary file. When I try to save the workspace, I get an error message saying the function can’t be executed while a file is mapped. I copied the data into a matrix then copied a vector form of the data to a different variable. I erased the variable to which the data was read thinking that perhaps this is keeping the file mapped, but still got the error. How do I break the connection to the mapped file so I can save the WS?
Posts: 33
Joined: Thu Jul 18, 2013 5:15 am

Re: Can’t save WS while file mapped

Postby Geoff|Dyalog on Mon Sep 25, 2017 11:11 am

⎕MAP produces an array that has reference semantics. Namespaces also have reference semantics.

You break these by using indexing. So
      a←80 1 2 3 ⎕map '/dev/zero'

maps /dev/zero which, on Unix/Linux/MacOs, is a "file" that reads as an infinite length - all zeros.
So I now have a 3 dimensional array of shape 1 2 3 that is all null character.
      )save ./junk.dws
Cannot perform operation with mapped files present.
)save ./junk.dws
./junk.dws saved Mon Sep 25 11:38:54 2017

The data is saved in the workspace as "b". You could equally have reused "a".

The mapping is also broken if all of the names that still reference it are reassigned.
      a←80 1 2 3 ⎕map '/dev/zero'
)save ./junk.dws
Cannot perform operation with mapped files present.
)save ./junk.dws
./junk.dws saved Mon Sep 25 12:01:14 2017

In this case the data is not saved in the workspace. No name still references it.
Posts: 43
Joined: Wed May 13, 2009 12:36 pm

Return to APL Chat

Who is online

Users browsing this forum: No registered users and 1 guest