Defining a class within a Jupyter notebook

General APL language issues

Defining a class within a Jupyter notebook

Postby mfleming on Sun Jun 23, 2019 9:30 pm

I've used the recent Jupyter notebook capability to develop and document APL code. I wanted to go a step further and define classes as well, but it seems that can only be done within the Dyalog Editor or by putting the text into an external script file. The closest I could come to doing so within the notebook kernel session was the rather awkward

Code: Select all
src← ⊂':Class Constants'
src,←⊂'  :Field Public False'
src,←⊂'  :Field Public True'
src,←⊂'  :Field Public Epsilon'
src,←⊂'  :Field Public Infinity'
src,←⊂'  :Field Public MaxRecursion'
src,←⊂'  ⍝ Constructor, Niladic'
src,←⊂'  ∇ new'
src,←⊂'    :Implements Constructor'
src,←⊂'    :Access Public'
src,←⊂'    True← 1'
src,←⊂'    False← 0'
src,←⊂'    Epsilon← 0.00001'
src,←⊂'    MaxRecursion← 5'
src,←⊂'  ∇'
src,←⊂':EndClass'
2⎕fix src


One can do multi-line dfns using the ]dinput user command, but I could find no equivalent for script input. This probably falls in the Why Would You Want To Do That category, but is there any similar mechanism for evaluating script text?

Thanks in advance,
~Mark
mfleming
 
Posts: 10
Joined: Sat Mar 02, 2019 11:09 pm

Re: Defining a class within a Jupyter notebook

Postby RichardP|Dyalog on Mon Jun 24, 2019 9:45 am

Hi Mark
Well you've just given me a bit of help there - I didn't know about ]Dinput

It doesn't look like there is currently a way to input scripted classes or namespaces directly in a notebook - of course you could ⎕FIX from a text file or nested character vector
      nscript←':Namespace myns' '∇ r←Echo input' 'r←input' '∇' ':Endnamespace'
⎕FIX nscript

We'll look into implementing multi-line :Namespace and :Class shortly
RichardP|Dyalog
 
Posts: 30
Joined: Fri Oct 12, 2018 3:05 pm

Re: Defining a class within a Jupyter notebook

Postby RichardP|Dyalog on Mon Jun 24, 2019 12:53 pm

Good news, Mark
We have now implemented support for scripted :Namespaces, :Classes and :Interfaces
The latest version of the kernel is available from https://github.com/Dyalog/dyalog-jupyter-kernel

https://github.com/Dyalog/dyalog-jupyte ... ng-content has been updated to reflect the new change
RichardP|Dyalog
 
Posts: 30
Joined: Fri Oct 12, 2018 3:05 pm

Re: Defining a class within a Jupyter notebook

Postby mfleming on Mon Jun 24, 2019 4:35 pm

Amazing!

I had an adviser years ago who was a real proponent of literate programming, but Knuth's tangle and weave tools were kind of primitive. Jupyter notebooks are a much more natural approach to documenting work.

Many thanks for the update,
~Mark
mfleming
 
Posts: 10
Joined: Sat Mar 02, 2019 11:09 pm


Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest