Attribute for "pure" procedures that do I/O

Just my 2 cents but I’ve always felt that the concept of purity (or more specifically impurity) should be more fine grain. Yes we can declare a procedure to be IMPURE but what I’m thinking about would be along the lines of two changes to the standard.

  1. First, allow for impure blocks (or scoping units) inside a otherwise pure procedure,

ie.
PURE Function a
BLOCK,IMPURE or BLOCK(IMPURE) etc
do some impure io on some variables that are local to the block
END BLOCK
End Function a

  1. Introduce the concept of PURE io by allowing a file to be declared a “PURE” file which would mean that it is effectively open as WRITE only (and cannot be reopened as READ/WRITE during the course of the execution. You would obvously want to be able to read it later but only after a STOP or ERROR STOP statement has closed the file

Open (newunit=pure_unit,file=“pure.dat”, ACCESS=PURE, Form=xxx, STATUS=xxx)

I’m sure there are a million reasons why this wouldn’t work and is probably undesirable but I’m just throwing a couple of thoughts out for discussion

1 Like