Hi Fred,

I had a look at the old code and saw that for ⍞ and ⎕ testcase files
are handled differently than script files.

I have recreated the old behavior in SVN 475.

I noticed that echo of the ⍞ input is off when GNU APL is run from a script.
I have not yet considered the combination of scripting with interactive input, so
I am not sure if this is OK. Or maybe such scripts should not run with --script (which implies
--noCIN).

/// Jürgen


On 09/15/2014 06:02 PM, Frederick H. Pitts wrote:
Hello Juergen,

	1) Up until at svn 443, ⍞ references were from the terminal for shell
scripts and files processed with 'apl -f'.  Sure of that because I just
checked out that and earlier svn versions and tested.  ⍞ references
being coupled to script APL source files and not the terminal is a
relatively recent change in how Gnu APL works.

	2) The "APL2 Programming: Language Reference" and "ISO/IEC
13751:2000(E)" give no indication that ⍞ is ever connected to anything
other than a terminal.

	3) If ⍞ references in shell script and apl -f processed files have to
be satisfied by reading from the apl source file, what is the point of
directing assignments to ⍞ to the terminal?  The user is not going to be
able to respond to the prompts, at least, not from the terminal.

Regards,

Fred

On Mon, 2014-09-15 at 14:28 +0200, Juergen Sauermann wrote:
Hi Fred,

first of all, please note that CORE_COUNT_WANTED= has currently no
effect since I am working on that.
I fixed Parallel.cc so that it compiles, SVN 473.

Regarding ⍞ your expectation seems to be that ⍞ always reads from the
terminal
even if the input comes from a file?

This is not so in GNU APL; ⍞ reads from stdin of the process and if
that is a file then the input
is read from the file. Your example below gives (anfd should give):

eedjsa@server65:~/apl/apl-1.4/src$ ./hello.apl 
What is your name?  Hello 


This is easier to undestand if we change the line before )OFF to
something non-empty:

#!./apl --script --
⍝ ------------------------------
∇hello; X
 ⍞ ← 'What is your name?  '
 X ← ⍞
 ⎕ ← 'Hello ', ( X ≠ ' ' ) / X
∇

hello
!!! this line is read by ⍞ in function hello !!!
)OFF
⍝ ------------------------------

This gives:

eedjsa@server65:~/apl/apl-1.4/src$ ./hello.apl 
What is your name?  Hello !!!thislineisreadby⍞infunctionhello!!!

So far everything looks OK, at least on my machine. Of cause you could
argue
if reading from stdin was a good choice in the first place. I believe
it was because:

- you cannot assume to always have a usable terminal
- testcase files (for testing ⍞ in particular)
- CGI scripts written in APL (which communicates with APL via stdin
and stdout)

/// Jürgen


On 09/15/2014 12:17 AM, Frederick H. Pitts wrote:

Hello Juergen,

	I cloned svn 472, configured and tried to build.  I find that if
I configure with CORE_COUNT_WANTED=argv, the following compiler error
results:

Parallel.cc: In static member function 'static void
Parallel::init_CPUs(bool)':
Parallel.cc:333:7: 'uprefs' was not declared in this scope
        uprefs.requested_cc;     // parallel, as per --cc option

A similar but differ error occurs if I use CORE_COUNT_WANTED=syl.

	If I configure without specifying CORE_COUNT_WANTED, the build
completes OK.  However I'm still having the problem of the ⍞ reference
not reading from the terminal.

	Something as simple as:

#!/usr/local/bin/apl --script --
⍝ ------------------------------
∇hello; X
 ⍞ ← 'What is your name?  '
 X ← ⍞
 ⎕ ← 'Hello ', ( X ≠ ' ' ) / X
∇

hello

)OFF
⍝ ------------------------------

demonstrates the issue.  If the above is executed as a shell script with

	./hello.apl

or the apl invocation

	apl -f hello.apl

the ⍞ reference input is not coming from the terminal.

Regards,

Fred

On Sun, 2014-09-14 at 16:27 +0200, Juergen Sauermann wrote:
Hi Fred,

Thanks. I see some debug outout at the end of your file:

      hello
What is your name?  
)SI not cleared at the end of ./hello.apl:
hello[2]  X ← ⍞
          ^
⋆  hello
   ^

That debug output should only occur if a testcase file is executed and
not for normal script file like your hello.apl. This should be fixed
in SVN 472.

------

Apart from that I can't really see what is wrong. The intended
behavior (and the actual behavior on
my box) is that GNU APL reads from input files as long as there are
unprocessed files and switch
to stdin after the last input file was processed.

In your case, hello.apl defines function hello and calls it on the
last line of hello.apl.
After having read the last line of hello.apl, the next input is read
from stdin:

      hello                       ← from script
What is your name?  Jürgen        ← from stdin
Hello Jürgen

If your box behaves differently then I need more details.

/// Jürgen



On 09/13/2014 03:31 AM, Frederick H. Pitts wrote:

Gentle people,

	As of SVN 470, ⍞ references are taking their input from the APL source
file instead of the terminal if there is any source file left to be
read.  It appears that the interpreter is starting to execute code
before the interpreter has completely consumed the source file and is
confusing the file input stream with the terminal stream.

	A file that demonstrates the error is attached.

Regards,

Fred



      



Reply via email to