SALT, dfns and ]Defs

For users of dfns, both novice and expert

SALT, dfns and ]Defs

Postby romilly on Wed May 04, 2016 6:49 am

I have a SALTed workspace that contains (only) dfns. They were created as one-liners but they now have two lines because SALT has added timestamps.

]Defs just lists names since the dfns are now multi-line.

I'm tempted to try to create my own variant of ]Defs but I am a Dyalog noob and there are already lots of things on my 'stuff to learn' list. What should I do?
romilly
 
Posts: 6
Joined: Tue May 03, 2016 9:51 am

Re: SALT, dfns and ]Defs

Postby JohnS|Dyalog on Wed May 04, 2016 7:16 am

It may be possible for ]defs to spot a SALTed one-liner and display the original (desalinated) version.
Thanks - will investigate.
User avatar
JohnS|Dyalog
 
Posts: 173
Joined: Wed Sep 10, 2008 10:01 am

Re: SALT, dfns and ]Defs

Postby Phil Last on Wed May 04, 2016 8:03 am

pro-tem you could do
      ↑{3↓⊃,/' ⋄ '∘,¨⎕nr ⍵}¨↓⎕nl 3.2 4.2
switching and if ⎕ML>1
      f00←{⍺+⍵}
f01←{⍺-⍵}
f02←{⍺×⍵}
f03←{⍺÷⍵}
↑{3↓⊃,/' ⋄ '∘,¨⎕NR ⍵}¨↓⎕NL 3.2 4.2
f00←{⍺+⍵}
f01←{⍺-⍵}
f02←{⍺×⍵}
f03←{⍺÷⍵}
⎕fx'f04←{⍺+⍵' '⍝' '}'
⎕fx'f05←{⍺-⍵' '⍝' '}'
⎕fx'f06←{⍺×⍵' '⍝' '}'
⎕fx'f07←{⍺÷⍵' '⍝' '}'
↑{3↓⊃,/' ⋄ '∘,¨⎕NR ⍵}¨↓⎕NL 3.2 4.2
f00←{⍺+⍵}
f01←{⍺-⍵}
f02←{⍺×⍵}
f03←{⍺÷⍵}
f04←{⍺+⍵ ⋄ ⍝ ⋄ }
f05←{⍺-⍵ ⋄ ⍝ ⋄ }
f06←{⍺×⍵ ⋄ ⍝ ⋄ }
f07←{⍺÷⍵ ⋄ ⍝ ⋄ }
User avatar
Phil Last
 
Posts: 464
Joined: Thu Jun 18, 2009 6:29 pm

Re: SALT, dfns and ]Defs

Postby Phil Last on Wed May 04, 2016 9:07 am

Which reminds me of a drawback pointed out some years ago by Richard Nabavi regarding dfns that I challenged at the time but which obviously doesn't trouble Romily. Richard's point can be paraphrased as "dfns discourage documentation". You can't put a trailing comment on a one-line dfn because the closing brace becomes, or would become, a part of the comment.
      f00←{⍺+⍵ ⍝ this cannot be fixed }
My proposed remedy then was
      f00←{⍺+⍵ ⊣ '⍝ whereas this can' }
[Actually not my idea. I believe I got it straight from KEI's "A Dictionary of APL"]
Rather than adding dependencies to one function, a user command, to accommodate peculiarities in an almost unrelated piece of software, SALT, perhaps the latter could itself be changed to cause less fundamental change to its client functions by not converting one-liners to multi-liners and instead adding a quoted comment after the left identity.
User avatar
Phil Last
 
Posts: 464
Joined: Thu Jun 18, 2009 6:29 pm

Re: SALT, dfns and ]Defs

Postby romilly on Wed May 04, 2016 10:21 am

First, thanks for the workaround, Phil, which works a treat.

I had not encountered the issue with comments in one-liners because I added comments after the dfns were salted. My workflow will now be:

1) create/test the dfn
2) salt it
3) add the comment at the end of the first line

That's ok but it would be nicer to be able to write the comment when I create the dfn.
romilly
 
Posts: 6
Joined: Tue May 03, 2016 9:51 am

Re: SALT, dfns and ]Defs

Postby Phil Last on Wed May 04, 2016 11:03 am

Incidentally, changing
      ↑{3↓⊃,/' ⋄ '∘,¨⎕NR ⍵}¨↓⎕NL 3.2 4.2
into
      {⎕←3↓⊃,/' ⋄ '∘,¨⎕NR ⍵}¨↓⎕NL 3.2 4.2
will overcome problems encountered if any of your dfns get too large to string out across the screen. By displaying each in turn only the culprits will wrap.
User avatar
Phil Last
 
Posts: 464
Joined: Thu Jun 18, 2009 6:29 pm

Re: SALT, dfns and ]Defs

Postby DanB|Dyalog on Wed May 04, 2016 3:12 pm

I have modified ]defs to ignore SALT tags. Will appear in the next Beta.
DanB|Dyalog
 


Return to Functional Programming

Who is online

Users browsing this forum: No registered users and 1 guest