Dyalog / link

Source code for Link – the built-in component that enables the use of text files as the primary storage mechanism for APL source code
https://dyalog.github.io/link
MIT License
19 stars 10 forks source link

Link is not present when running APL with redirected input #283

Closed bernecky closed 3 years ago

bernecky commented 3 years ago

I am trying to set up the apex compiler with automation for unit testing. If I start APL with the /opt...mapl below, then enter the junk←⎕se... text below, it works fine, spitting out the useless, yet still irritating, "watch defaults" text, but it does set up the links.

However, if I redirect a text file as mapl as stdin, APL appears unable to find ]Link, as below. I assume I am missing something that is documented somewhere, so would appreciate a hint or three.

apex@boa:~/apexgit$ cat crud.in | /opt/mdyalog/18.0/64/unicode/mapl 
Dyalog APL/S-64 Version 18.0.40273
Serial number: UNREGISTERED - not for commercial use
+-----------------------------------------------------------------+
| Dyalog is free for non-commercial use but is not free software. |
| A non-commercial licence can be used for experiments and        |
| proof of concept until the point in time that it is of value.   |
| For further information visit                                   |
| https://www.dyalog.com/prices-and-licences.htm                  |
+-----------------------------------------------------------------+
Copyright (c) Dyalog Limited 1982-2021
      ⍳4
0 1 2 3
      junk←⎕SE.Link.Create'#' 'Source/Root'
VALUE ERROR: Undefined name: Link
      junk←⎕SE.Link.Create'#' 'Source/Root'
               ∧
apex@boa:~/apexgit$ cat crud.in 
⍳4
junk←⎕SE.Link.Create'#' 'Source/Root'
apex'Ancillary/benchmks/benchmksAPL/iotan'
bernecky commented 3 years ago

Apparently, I am not the only person in need of an assist here, as this just arrived from a colleague in Nova Scotia:

I have ran into a problem with loading the apex workspace. When I load it, dyalog is saying that something 
doesn't exist when it should exist. Am I loading the workspace incorrectly? ...

/app/wss/apex.dws saved Wed Aug 11 23:28:30 2021
VALUE ERROR: Undefined name: Link
      junk←⎕SE.Link.Create'#' 'Source/Root'

You can try it out yourself with this command below, but replace the /app/wss/apex.dws with your 
apex workspace path.

echo "bm←benchmks.benchmks'Ancillary/benchmks/UnitTests' ⋄
     z←⍪(⊆'targetLanguage=sac')apex¨bm" | dyalog -s -b /app/wss/apex.dws
mkromberg commented 3 years ago

This is caused by the Dyalog interpreter deciding that you should have a completely clean slate when running a script file, without any development tools loaded. Can you check whether adding the following as the first line of your script sorts things out?

  (⎕NS⍬).({}enableSALT⊣⎕CY'salt')
mkromberg commented 3 years ago

Documents updated with an additional paragraph on scripted applications, see https://dyalog.github.io/link/3.0/Usage/Setup/.

bernecky commented 3 years ago

Well, that did not work, so I am going to have to RTMM (Read The Morten Manual).

cat crud.in | /opt/mdyalog/18.0/64/unicode/mapl 
Dyalog APL/S-64 Version 18.0.40273
Serial number: UNREGISTERED - not for commercial use
+-----------------------------------------------------------------+
| Dyalog is free for non-commercial use but is not free software. |
| A non-commercial licence can be used for experiments and        |
| proof of concept until the point in time that it is of value.   |
| For further information visit                                   |
| https://www.dyalog.com/prices-and-licences.htm                  |
+-----------------------------------------------------------------+
Copyright (c) Dyalog Limited 1982-2021
       (⎕NS⍬).({}enableSALT⊣⎕CY'salt')
SALT initialization failed: 

      ⍳5
0 1 2 3 4
      ⍝ )load wss/apex.dws
      ,⎕sh'pwd'
 /home/apex/apexgit 
      z←apex'Ancillary/benchmks/benchmksAPL/iotan'
VALUE ERROR: Undefined name: apex
      z←apex'Ancillary/benchmks/benchmksAPL/iotan'
        ∧
apex@boa:~/apexgit$ cat crud.in 
 (⎕NS⍬).({}enableSALT⊣⎕CY'salt')

⍳5
⍝ )load wss/apex.dws
,⎕sh'pwd'
z←apex'Ancillary/benchmks/benchmksAPL/iotan'
⎕←z
bernecky commented 3 years ago

No better this way:

      (⎕NS⍬).({}enableSALT⊣⎕CY'/opt/mdyalog/18.0/64/unicode/ws/salt.dws')
SALT initialization failed: 

I am going to try the latest 18.0 interpreter and see if works any better. It works worse:

Dyalog APL/S-64 Version 18.0.40684
Serial number: UNREGISTERED - not for commercial use
+-----------------------------------------------------------------+
| Dyalog is free for non-commercial use but is not free software. |
| A non-commercial licence can be used for experiments and        |
| proof of concept until the point in time that it is of value.   |
| For further information visit                                   |
| https://www.dyalog.com/prices-and-licences.htm                  |
+-----------------------------------------------------------------+
Fri Sep  3 15:34:59 2021
*** Fixing "/opt/mdyalog/18.0/64/unicode/StartupSession/Link/Watcher.apln" into ⎕SE.Link caused a DOMAIN ERROR (There were errors pr
      ocessing the script)

Rebuilding user command cache... done

Let's pick up the latest Link from github. Better - the DOMAIN ERROR went away. We still this annoying warning from Link.

     )load wss/apex.dws
wss/apex.dws saved Thu Aug 19 13:34:44 2021
Link Warning: ⎕SE.Link.Create: .NET or .NetCore not available - watch defaults to 'ns'

However, the script is still busted, but in a new way:

Dyalog APL/S-64 Version 18.0.40684
Serial number: UNREGISTERED - not for commercial use
+-----------------------------------------------------------------+
| Dyalog is free for non-commercial use but is not free software. |
| A non-commercial licence can be used for experiments and        |
| proof of concept until the point in time that it is of value.   |
| For further information visit                                   |
| https://www.dyalog.com/prices-and-licences.htm                  |
+-----------------------------------------------------------------+
Copyright (c) Dyalog Limited 1982-2021
      (⎕NS⍬).({}enableSALT⊣⎕CY'salt')
SALT initialization failed: 
      ⍳5
0 1 2 3 4
      )load wss/apex.dws
Cannot perform operation when # is referenced by session namespace.

Once again, with feeling. And with the full workspace path.

Copyright (c) Dyalog Limited 1982-2021
      (⎕NS⍬).({}enableSALT⊣⎕CY'/opt/mdyalog/18.0/64/unicode/ws/salt.dws')
SALT initialization failed: 
      ⍳5
0 1 2 3 4
      )load wss/apex.dws
Cannot perform operation when # is referenced by session namespace.
mkromberg commented 3 years ago

Are you able to trace into the expression and see where enableSALT is coming off the rails? The error message on )load means something should have been cleaned up by the error handling code, but was not.

Also, can you try:

(⎕NS⍬).({}enableSALT⊣⎕CY'salt'⊣⎕ML ⎕IO←1 1)

bernecky commented 3 years ago

Here's what I get with your latest expression, Morten:

cat crud.in 
 ⍝⍝   (⎕NS⍬).({}enableSALT⊣⎕CY'/opt/mdyalog/18.0/64/unicode/ws/salt.dws')
(⎕NS⍬).({}enableSALT⊣⎕CY'salt'⊣⎕ML ⎕IO←1 1)
⍳5
)load wss/apex.dws
,⎕sh'pwd'
z←apex'Ancillary/benchmks/benchmksAPL/iotan'
⎕←z

apex@boa:~/apexgit$ cat crud.in | /opt/mdyalog/18.0/64/unicode/mapl 
Dyalog APL/S-64 Version 18.0.40684
Serial number: UNREGISTERED - not for commercial use
+-----------------------------------------------------------------+
| Dyalog is free for non-commercial use but is not free software. |
| A non-commercial licence can be used for experiments and        |
| proof of concept until the point in time that it is of value.   |
| For further information visit                                   |
| https://www.dyalog.com/prices-and-licences.htm                  |
+-----------------------------------------------------------------+
Copyright (c) Dyalog Limited 1982-2021
       ⍝⍝   (⎕NS⍬).({}enableSALT⊣⎕CY'/opt/mdyalog/18.0/64/unicode/ws/salt.dws')
      (⎕NS⍬).({}enableSALT⊣⎕CY'salt'⊣⎕ML ⎕IO←1 1)
SALT initialization failed: 
      ⍳5
0 1 2 3 4
      )load wss/apex.dws
Cannot perform operation when # is referenced by session namespace.
      ,⎕sh'pwd'
 /home/apex/apexgit 
      z←apex'Ancillary/benchmks/benchmksAPL/iotan'
VALUE ERROR: Undefined name: apex
      z←apex'Ancillary/benchmks/benchmksAPL/iotan'
        ∧
apex@boa:~/apexgit$ 

Then, I tried this:

)xload /tmp/salttmp.dws saved Mon Sep  6 15:40:58 2021
      ⎕vr'enableSALTcrud'
     ∇ msg←enableSALTcrud;ok                                                  
[1]   ⍝ Set the registry setting for SALT telling it to react on Editor events
[2]    :If 0∊⎕SE.⎕NC'UCMD' 'SALT' 'SALTUtils'                                 
[3]        ⎕←'if ucmd taken'                                                  
[4]        :Trap 0                                                            
[5]            ok←0                                                           
[6]            BUILD_DYALOGSPACE                                              
[7]            ok←1                                                           
[8]        :EndTrap                                                           
[9]        :If 0∊ok,WSLoaded 1                                                
[10]           msg←'** Unable to boot SALT'                                   
[11]           :Return                                                        
[12]       :EndIf                                                             
[13]   :EndIf                                                                 
[14]   :If ∨/'0nN'∊getEnvir'SALT\AddSALT'                                     
[15]       ⎕←'if onN taken'                                                   
[16]       regPutString'SALT\AddSALT' '1'                                     
[17]       msg←'SALT now reacts to Editor events'                             
[18]   :Else                                                                  
[19]       msg←'SALT already reacts to Editor events'                         
[20]   :EndIf                                        
cat crud.in 
 ⍝⍝   (⎕NS⍬).({}enableSALT⊣⎕CY'/opt/mdyalog/18.0/64/unicode/ws/salt.dws')
 (⎕NS⍬).({}enableSALTcrud⊣⎕CY'/tmp/salttmp.dws')
 ⍝⍝⍝ (⎕NS⍬).({}enableSALTcrud⊣⎕CY'salt'⊣⎕ML ⎕IO←1 1)
⍳4
)load wss/apex.dws
,⎕sh'pwd'
z←apex'Ancillary/benchmks/benchmksAPL/iotan'
⎕←z

apex@boa:~/apexgit$ cat crud.in | /opt/mdyalog/18.0/64/unicode/mapl 
Dyalog APL/S-64 Version 18.0.40684
Serial number: UNREGISTERED - not for commercial use
+-----------------------------------------------------------------+
| Dyalog is free for non-commercial use but is not free software. |
| A non-commercial licence can be used for experiments and        |
| proof of concept until the point in time that it is of value.   |
| For further information visit                                   |
| https://www.dyalog.com/prices-and-licences.htm                  |
+-----------------------------------------------------------------+
Copyright (c) Dyalog Limited 1982-2021
       ⍝⍝   (⎕NS⍬).({}enableSALT⊣⎕CY'/opt/mdyalog/18.0/64/unicode/ws/salt.dws')
       (⎕NS⍬).({}enableSALTcrud⊣⎕CY'/tmp/salttmp.dws')
if ucmd taken
*** Fixing "/opt/mdyalog/18.0/64/unicode/StartupSession/Link/Watcher.apln" into ⎕SE.Link caused a DOMAIN E
      RROR (There were errors processing the script)
SALT initialization failed: 
       ⍝⍝⍝ (⎕NS⍬).({}enableSALTcrud⊣⎕CY'salt'⊣⎕ML ⎕IO←1 1)
      ⍳4
0 1 2 3
      )load wss/apex.dws
wss/apex.dws saved Thu Aug 19 13:34:44 2021
SYNTAX ERROR
      junk←⎕SE.Link.Create'#' 'Source/Root'
           ∧

That suggests to me that it is failing in BUILD_DYALOGSPACE.

mkromberg commented 3 years ago

Thanks, I see the problem. Opened and fixed #331. We have a new process which means my PR's will be delayed a bit for review before hitting the master branch. A really quick fix which I think should work for you is to comment out the line in Watcher.apln which reads:

ErrorCrawler←'⎕SE.Link.Crawler'∘##.U.Error