In article <
[email protected]>,
Anton Ertl <
[email protected]> wrote:
[email protected] writes:
I typically restart the application by restarting the Forth system and >>>reloading the application source.
With ample memory it is not worthwhile to restart the Forth system.
As if that was costly.
Merely inconvenient.
With ciforth making executables is easy.
Easy is still harder than doing nothing.
It is so easy that it pays off not loading the source several times,
even with command repeaters like rlwrap.
The situation is that you want to run programs with different parameters,
e.g. projecteuler.net with increasing sizes, the last one several hours. Reloading the source is just a waste of time, but more importantly
a distraction.
$EDITOR aap.frt
..
make aap
With a line in the Makefile
%: %.frt ; $(FORTH) -c $<
With a Forth system and an OS (like Unix) that have good support for >executing scripts, the Forth source code can just serve as script; if
you want to call the script without mentioning the Forth system, you
can put the Forth system in the hash-bang line in Unix, e.g.
#! /usr/bin/gforth
or
#! /usr/bin/env gforth
as first line (the latter is beneficial if you don't know whether
gforth is in /usr/bin or /usr/local/bin on the systems where the
script is invoked). Ok, you still have to do that and make the file >executable, but you don't have to repeat that every time you change
the program source, while you have to rebuild the binary executable
every time, however easy that may be.
<SNIP>
Here's an example:
[/tmp:147807] cat <<EOF >example
#! /usr/bin/env gforth
: echo ( -- )
begin
next-arg 2dup 0 0 d<> while
type space
repeat
2drop ;
echo cr bye
EOF
[/tmp:147808] chmod +x example
[/tmp:147809] ./example a b c d
a b c d
If I edit example, I don't have to repeat the chmod.
Here is the take on this with ciforth
----------------------------
#!/usr/bin/lina -s
BEGIN ARGC 1 > WHILE 1 ARG[] TYPE SPACE SHIFT-ARGS REPEAT
CR
----------------------------
~/PROJECT/ciforths/ciforth: script a b c d
a b c d
- You specify with -s that you run a script
- No space after #! , that is a pitfall.
- in scripting you want to run interpretive control structures
more than normal
- Of course you must chmod.
Options are convenient, because Forth has many faces,
interactive trying, scripting, compilation, debugging, developing,
ease of use at the cost of occasional failure.
none : bald interpreter
-a : library attached
-c : compile
-s : script
-n : newbie, autoload from library
-e : electives, development tools
Read once through the applicable chapter and you at least
remember how to do things. Option -s is not hard to
associate with scripts.
- anton
Groetjes Albert
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat purring. - the Wise from Antrim -
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)