SALT, dfns and ]Defs

For users of dfns, both novice and expert
Post Reply
romilly
Posts: 6
Joined: Tue May 03, 2016 9:51 am

SALT, dfns and ]Defs

Post by romilly »

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?
JohnS|Dyalog

Re: SALT, dfns and ]Defs

Post by JohnS|Dyalog »

It may be possible for ]defs to spot a SALTed one-liner and display the original (desalinated) version.
Thanks - will investigate.
User avatar
Phil Last
Posts: 628
Joined: Thu Jun 18, 2009 6:29 pm
Location: Wessex

Re: SALT, dfns and ]Defs

Post by Phil Last »

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: 628
Joined: Thu Jun 18, 2009 6:29 pm
Location: Wessex

Re: SALT, dfns and ]Defs

Post by Phil Last »

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.
romilly
Posts: 6
Joined: Tue May 03, 2016 9:51 am

Re: SALT, dfns and ]Defs

Post by romilly »

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.
User avatar
Phil Last
Posts: 628
Joined: Thu Jun 18, 2009 6:29 pm
Location: Wessex

Re: SALT, dfns and ]Defs

Post by Phil Last »

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.
DanB|Dyalog

Re: SALT, dfns and ]Defs

Post by DanB|Dyalog »

I have modified ]defs to ignore SALT tags. Will appear in the next Beta.
Post Reply