link icon indicating copy to clipboard operation
link copied to clipboard

Links should change file extension when the type of a name changes

Open aplteam opened this issue 3 years ago • 3 comments

The way Link deals with objects changes leads to problems

For example, this function is saved with the extension `.aplf``:

Hello←{'World'}

Converting a trad function into an operator is not exactly difficult, but with a dfn it's even easier:

Hello←{⍺⍺'World'}

Now it's an operator, and indeed does Link save this a Hello.aplo, which is good.

What is bad is that it leaves behind the file Hello.aplf, meaning that the next time one executes ]Link.Create on that folder this error will be reported:

ERRORS ENCOUNTERED: ⎕SE.Link.Create: Files produce clashing APL names:
 C:\...\Hello.aplf  ←→  #.Foo.MyFn                                
 D:\...\Hello.aplo  ←→  #.Foo.MyFn                                

Since it is impossible to have a function and an operator with the same name, I don't see why Link should not delete `Hello.aplf``.

Something similar needs to happen when a namespace script is changed into a class etc.

I am on Link 3.1.1

(This is my <01968>)

aplteam avatar Feb 21 '22 12:02 aplteam

I've hit exactly the situation you describe in the last sentence: I was working with a class which I then rewrote to be a namespace. That all worked fine - but it still used an .aplc file to store the code. I would be fine(r), I think, if the extension would change as well to reflect the change of type.

mbaas2 avatar Mar 18 '22 15:03 mbaas2

I think we should update the extension IF a name changes type AND the existing extension is the default extension for the old type. I think that covers your failing cases, but leaves the name alone if the extension is .dyalog. Note that you can specify -forceExtensions to have Link always use "the correct" extension.

mkromberg avatar Mar 19 '22 08:03 mkromberg