By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Version 28 LIBRARY changes have side effects

/R has been modified to qualify function names with the name of the library.
/F now lists the functions with their qualified names.

If you have a cycle where you compose your library with several source files expecting to write them out again to a single file, that file is now unusable as a source file. Upon rereading the single file the library functions are doubly qualified.

This is quite usefull when managing SETtings, aliases and functions.

Could /N be redefined as
/R /N - do not qualify added / updated functions
/F /N - remove library names from the functions listed?

Regards, DJ
I don't understand what you're trying to do -- generate a library containing libraries?

How are you combining your multiple library files into a single file?

/R /N wouldn't work, as ALL functions are now required to have library names added when they're loaded in order for LIBRARY to find & execute them.

/F /N could be done, but seems pointless.
In short, I restore my general environment by restoring frozen states per list-type (envars, aliases, functions and library functions and others). Much faster and simpler startup code. The frozen states are generated by separate source files that only update the f-states when changes to the source are detected.

And yes, I use

:: Creating a frozen state, only rarely.
set envar1=value1
set envar2=value2
set * >! set_of_values.SAVED

:: Reusing it frequently.
set /R set_of_values.SAVED

I have the same setup for aliases and functions.
Through the years my source files have grown considerably and contain a wealth of information about the history of its contents. When was what changed into what and for what reason.

It has allowed me to create general purpose environments with application- and hardware-specific specializations that are easy to track, maintain and communicate to end-users.

I understand that by qualifying the library functions with their filename you are trying to prevent name-collisions. I pointed out that your chosen design, contrary to the case of envars, aliases and functions, breaks the expectation of reusability by modifying the original content. Now, LIBRARY * >! set_of_functions.SAVED is useless.

My request is, that you restore the reusability of the output, by whatever option of your choosing.

And, now that we are on this topic, another surprising design choice comes to mind. It seems that upon reading the source with LIBRARY /R you also remove leading whitespace. I understand that it reduces size a little and is slightly speeds up the interpreter but, why would you not remove comments, then?

It took me a couple of minutes to come up with a perl script that does the trick:
use strict;
use warnings;

while (<>) {
    # Skip comment blocks
    next if /COMMENT/../ENDCOMMENT/;
    # Remove Leading whitespace
    # Remove single line comments
    # Skip white lines
    next if m/^\s*$/;

However trying to duplicate this using TPIPE has me stumped, even after hours of trying.

I'll be interrested in hearing your thoughts.

Regards, Dirk Jan.
There seems to be a common misconception that libraries are like aliases or functions that support multiple lines. In fact, they have nothing whatever in common, and share 0% code. Libraries are actually like little batch files that live in memory all the time; this is what allows the debugger to step through them. (Something that cannot be done with aliases or user-defined functions.)

What you're doing is the opposite of the way I intended to have libraries work, and doesn't make any more sense to me than having all of your batch files saved as one gigantic batch file. And it would make it pretty much impossible to have third-party library files as there would be endless name conflicts. It also would mean LIBRARY /R could only read a single file.

However -- I made a change in LIBRARY /R for the next build that looks to see if the function name already contains a '$'; if so it won't add another one (filename$function). This will allow you to use your single saved library file. Not supported and definitely not recommended, but it should work for you.

Libraries strip whitespace, blank lines, and comments outside of function declarations; comments inside the function are maintained (by user request) so they will be visible in the batch debugger.
[FOX] Ultimate Translator