Saturday, December 29, 2018

File names as iterators

The goal is to promote file naming convention to first class objects. Here is a proposal, the forward slash means: 'to iterate on':

home/me                    // me is a selection of home which is indexable.

/home                    // home is an iterator of the null set.

./file                 // An iteration on the current set

Then we have:

FILE * fin = /home/me/myfile.ext;   // no quotes, and the name is parsed

 The absolute pointer to fin found, up to but not including any change of state for fin. But, after the statement:

fopen(fin);  // works fine

Then, of course, the iterator function predefined and typed elsewhere.  Thus, the files module need only write iteration methods, the parsing and identifying of files pushed up to the syntax engine.

For namespace organization:

execl(/Xchars/OutString, rect, str);  // works fine, no quote neede3d

I have redefined chars as a specific form of iterable set, wrote the methods. The method in this case is a sub table look up for each '/'. The last look up should reveal a terminal, executable at the linux level.
Or at the console loop:

./Xchars/OutSring rect "Hello World";

The process of identifying which form of the forward slash is context dependent according to typedef, relative precedence with expression operators, and syntax definition. The Default standard is that all selector/selected methods refer to a snippet, thus relieving the console loop of bloat. If no method is available, the default selector methods keeps the whole string and defers its parsing to places unknown down stream. Default thus has a restriction in its document: Default limits the use of thge general selector types to snippet accessable entry table.  That is, all Default can select on is a list of entries in a module subdommand table.  A restriction because Default restricts itself to default-like things, things that would happen if no module was loaded or no configuration applied. However, Default will support redirection of the selector function to another snippet entry point.

Snippet MySnippet;
home = /MySnippet/mysubcommand;

Or:
Snippet FILE;
FILE * = /Myroot/me/file;  // works fine

Identify FILE as equivalent to a snippet. Then point to its method and parse the file name. In this case, the entry table for the FILE module is the directory itself. The name is tokenized up front, but Default knows what to do and on execution will directly sift through the file directory, unknowingly performing the ls function. It works because it is all driven from the same symbol table format implied in the universal interface.

The slash solves the command line macro problem:

Iter X = /Xchars; // Causes Default to look up the name Xchars and attach it to X

so:

X named_subcommand arg...; // X is expanded inside the Default interpreter.,

Xchars precedes the actual command on output. This works on default because of the common symbol table with ExecCommand, but it needs a few lines of code. 

But his whole discussion is about introducing the iterator method in a form we already are destined to use anyway. Context specific use is not bad, easy for humans. We do the context specific with ++, <<; the doubles, we do it a bit with brackets and semi-colon. Let us reframe the forward slash, just use the file name syntax for all sort of set selection, like the python iterator.

Facts are facts, we are not giving up the linux file naming syntax, not me, you or anyone else, so just accept the forward slash generic iterator function; And, selection is is the most functional equivalent to divide in set theory anyway so the reuse of forward slash is intuitive.

No comments: