{-- Mon, 15 Apr 2013 03:03:55 -0400: Enoch <i...@hotmail.com> wrote: --}

  Enoch> Hello Matthias & All:
  Enoch> amforth-shell.py bugfix. skips already uploaded #include files.

  Enoch> http://pastebin.com/ePa76LmL

I can see how this would be useful in some circumstances.  However, in
interactive development I upload the same file many times after making
changes to it, often with the use of marker words temporarily embedded
in the file.  For that reason I would prefer that this not be included
in the main distribution unless there is a method to turn the checking
on/off, preferably with a default value of off.

This got me wondering if what would be more useful is a

    #require <file>

directive as an alternative to

    #include <file>

The way I would implement "#require <file>" is that it would attempt to
execute the word "<file-basename>-provided", where <file-basename> is
replaced with the name of the specified file with any path to reach the
file and any ".frt" extension stripped.  So, if the directive were:

   #require lib/marker.frt

The word that would be executed would be:

   marker-provided

If this word can be executed without error it indicates the required
file has already been uploaded and thus the upload can be skipped,
otherwise the file is uploaded just as it is in the #include directive.

I would not have the "#require" implementation do anything to create the
"<file-basename>-provided" word.  Instead, I'd let the library itself do
that so that the library can determine what the definition of that word
should be.  To guard against usage of "#require" with libraries that do
not create "<file-basename>-provided" I would have the "#require"
implementation verify it *can* successfully execute the that word on the
target after the upload and print a warning if it can not.

I suspect this would address the use case that the suggested change is
intended to support while allowing the user of the shell to clearly
express the kind of behavior they want without having to be aware of
configuration settings/flags.

On a related note, I've also considered having #include automatically
establish a markers named "marker-before-<file-basename>" before a
library is loaded and call this during it is reloaded as a convenience.
Up until now I avoided doing this because I didn't want the shell to
require any non-default words.  However, I think this could be nicely
combined with some of the infrastructure the "#require" functionality
would need in the shell, in the following way:

  1. Have the marker library create marker-provided
  2. In #include:
     a. Check for marker-provided.  If it is not present skip the
        following two steps
     b. Before uploading the file, attempt to execute
        "marker-before-<file-basename>", ignoring any error
     c. Create a new "marker-before-<file-basename>"
     d. Continue with the upload

The nice thing about this is it only takes effect if you load the marker
library.  So you can do things like load marker.frt during development
but then not load it when you are ready to create a production image in
which you don't want the markers, etc.

Unfortunately, I don't have time to work on any of this right now.
Hopefully these thoughts are at least useful to the discussion.

      --- Keith

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to