the-carlisle-group / Acre-Desktop

A simple Dyalog APL IDE plugin that introduces "projects" and allows you to keep your source code in Unicode text files.
MIT License
11 stars 1 forks source link

Version Proofing Acre #136

Closed PaulMansour closed 5 years ago

PaulMansour commented 5 years ago

One of the big advantages of Acre (and text files) is that you can open up code written in any version of Dyalog. Acre itself, however is written in a particular version of Dyalog, and assumes a certain minimum level of Dyalog to run.

It would be useful to use Acre on older projects written in say, v14. It would also very useful to not have to worry about new versions of Acre that might be saved in a version of APL this ahead of my version of APL.

Normally I am of the school of "everybody should just update" and I don't like doing work to make sure old things run. However, Acre is a development tool and one of its main uses to avoid the version issue of Dyalog saved workspaces.

Thus I propose: Acre is written in the most recent version of Dyalog APL. However it runs in any version of Dyalog 14.1 or later (say). Obviously this means Phil has to check what version he is running in, and act accordingly. For example, he will need to cover NGET, NPUT etc. He will only be able use iota underbar if in a late enough version.

The user command distribution is delivered as v14.1 workspace, so no matter what version of APL the developer has, he can use it no problem. There is no need to build various versions, no need to worry if you have the right version or not.

As time marches on, we can up the minimum version, and Phil could remove code, but probably not worth the effort, and I'm likely to be dead by then.

New features or behaviors that cannot work in early versions of APL but might be useful in V18 or v19 can be introduced - they simply gracefully disappear if you are using V14.

This is some work obviously, but I don't think too much, and I think critical for adoption of Acre.

I think we only need to worry about Unicode, and when backporting for 14.1, windows only.

I think it should be a priority.

Thoughts?

norberturkiewicz commented 5 years ago

I'd like to make 14.0 the minimum,

PhilLast commented 5 years ago
 c_←{⍺←⊢
     SV.aplver>15:⍺⊆⍵
     1≡⍺ 1:⊂⍣(1=≡⍵)⊢⍵
     ⎕ML←3 ⋄ ⍺⊂⍵
⍝ ⊆ - m: enclose if simple
⍝ ⊆ - d: partition as per ⎕ML←3
⍝ Phil 2018-12-05 19.52
 }

Above is an emulator function for as 'c_'.

I just saved a v14.0 dws containing the function. If I then )LOAD or )COPY it into a v16.0 session it fails with a SYNTAX ERROR on the primitive. If I refix it with ⎕FX ⎕NR'c_' it works fine.

I suggest instead of an acre.dws we distribute the whole or a cut-down version of the source code and a separate stand-alone '\build.aplf' written in v14.0 and using only v14.0 functionality that builds and saves the installation ws into whichever version it's fixed.

norberturkiewicz commented 5 years ago

This is me just thinking out loud...

What about a wprks[ace and a second library workspace. The generic v14 workspace would load the appropriate native code from another source if it detects a compatible interpreter.

PhilLast commented 5 years ago

Certainly possible but producing those wss will still need something akin to my suggestion above for backfeeding code developed in one version into previous versions - which almost works as a single function in a dyapp! Should be tomorrow.

PhilLast commented 5 years ago

No. A dyapp is no good. It has the benefit that Dyalog sets the origin folder as the current directory but it always invokes the default - usually latest - Dyalog version.

Trying to make this as painless as possible.

norberturkiewicz commented 5 years ago

@PhilLast do I understand correctly that we need a very generic bootstrap .dws file that can build Acre-Desktop from the source code.

PhilLast commented 5 years ago

Done. More-or-less. Runs in 14.0 but of course the actual installation routine and the rest of acre don't. Yet.

 buildWsVersion←{
     ⎕IO←⎕ML←0 ⋄ LF CR BOM←⎕UCS 10 13 65279
     len←≢CD←(⊃⎕CMD'cd'),'/APLSource/'
     src←⎕CMD'dir "',CD,'_code-0/" /S'
     src⊢←(⊢(/⍨)1<≢¨)(⊢⊂⍨' '=⊃¨)(⊢(/⍨)0='<'∊¨⊢)~∘∊⍨src
⍝        lose single, partition,  lose <DIR>,  lose blank
     fns dir←⊢∘⊃¨\⌽↓⍉↑1(↑{⍺ ⍵}↓)¨src
     drop←{+/⍺≥+\2</0,' '≠⍵}
     dir⊢←(2 drop⊃dir)↓¨dir
     fns⊢←(3 drop⊃⊃fns)↓¨¨fns
     read←{CR(1↓¨=⊂⊢)CR,~∘(LF,BOM)⊢'UTF-8'⎕UCS ⎕UCS ⎕NREAD ⍵,80,⎕NSIZE ⍵}
     get←((⎕NUNTIE⊢read)0 ⎕NTIE⍨,)
     data←(dir,¨'/'){⍺∘get¨⍵}¨fns
     ns←(⍎''⎕NS⍨⊢)¨{{('..',⍵)[('\/',⍵)⍳⍵]}~∘('-',⎕D)⊢'#.acre.',len↓⍵}¨dir
     fns←ns.(⎕FX¨)data
     #.⎕LX←'#.acre._code.Install'''''
     .
⍝ this fn runs in a clear ws.
⍝ ⊃⎕CMD'cd' is assumed to be the acre development folder
 }

You have to get this into a clear ws of the Dyalog version of choice, set the current directory as the acre development folder and it stops after getting in the code and setting ⎕LX to run Install that associates the user commands.

But before running it you have to create your version specific installation folder and save it there, least confusingly as acre.dws.

At the moment you have to paste it into the session but it could be changed to be accessible some other way and to take the acre devt folder as argument and have the current directory as an already created installation folder. What I've been aiming at is an automatic way to run it by just a click but I'm moving towards putting the function in a ws on its own as its own ⎕LX and request the two folders through a BrowseBox.

e9gille commented 5 years ago

I'm not sure I follow Phil, but remember that the bootstrap loader also must support all platforms for new versions of Dyalog, so you can't rely on the dir command as you do above (if the intention is that buildWsVersion is to be run to install acre on any supported version).

PhilLast commented 5 years ago

Currently in test I'm working on win alone and writing emulators for pre. v16.0 stuff. (haven't got to v17.0 yet.) So far ⍸, ⊆, @, ⎕NPUT & ⎕NGET but only insofar as acre requires them.

dir gives me everything I need to cover the current uses acre makes of ⎕NINFO on whose emulator I've just started but I already have most of what I need in the fn above. Kai has pointed me to ls for mac & nix and I believe ⎕SH & ⎕CMD are interchangeable synonyms.

I'll need another flag or to extend aplver - that makes #.APLVersion more manageable - to two items to cover the OS as well as Dyalog version. And in time I'll swap in the respective emulators at startup or even build or install rather than running the conditional each time it's required. I guess startup is the best time to avoid the having to create a dozen or more wss for all combinations.

Hopefully within mac and nix the output of ls is fairly standard and as predictable and easily parseable as that of dir.

PaulMansour commented 5 years ago

Done!