Dyalog / link

Source code for Link – the built-in component that enables the use of text files as the primary storage mechanism for APL source code
https://dyalog.github.io/link
MIT License
19 stars 11 forks source link

Saving arrays with text:plain does not always do what it should #647

Closed aplteam closed 1 month ago

aplteam commented 1 month ago

I have text:plain in my configuration file.

When I do:

 v←'abc' 'xyz'
 ⎕SE.Link.Add'v'

Link creates a file v.vec.apla. When I do:

 v←↑'abc' 'xyz'
 ⎕SE.Link.Add'v'

Link creates a file v.mat.apla.

But when I do:

 v←'abc',(⎕UCS 13),'xyz'
 ⎕SE.Link.Add'v'

Link creates a file v.apla, NOT the expected v.CR.apla.

'abc',(⎕UCS 10),'xyz' and 'abc',(⎕UCS 13 10),'xyz' do not work as expected either.

abrudz commented 1 month ago

This is by design. Per the documentation, for a simple vector to be stored as plain text, it must have each line terminated by one of the supported line endings. In your examples, the last line fails to be terminated by the line ending in question. This design was chosen to align with the POSIX standard for text files. See Why should text files end with a newline? for details.