How to use ]Link.Create beforeRead hook?

SALT, SPICE, Subversion, etc...

How to use ]Link.Create beforeRead hook?

Postby zaibot.w on Tue Aug 10, 2021 2:35 pm

Hi,

I'm experimenting with ]Link and I'm trying to add a hook. Somehow, the following code doesn't work for me, so can anyone give a hint what I'm doing wrong?

Code: Select all
  load←⎕ns''
  load.beforeRead←{⎕this.called+←1 ⋄ 1}
  load.called←0
  options←⎕ns''
  options.beforeRead←'load.beforeRead'
  options ⎕SE.Link.Create 'ws'  '/path/to/ws'
⍝ load.called still returns 0


I'm on Dyalog version:
Version: 18.0.39803.0 64 Unicode
Created: Jan 7 2021 at 20:02:30
Build ID: 4d00828c

[EDIT:] Additional info: My link version seems to be 2.0.5. It semes that hooks were already implemented back then, because if I pass an empty opts namespace, I get variables beforeRead and beforeWrite after executing LINK.Create, however, when debugging I can't find any reference, where these options are used. When did you introduce the hooks?

Thank you very much!
Tobias
zaibot.w
 
Posts: 6
Joined: Mon Jun 29, 2020 4:09 pm

Re: How to use ]Link.Create beforeRead hook?

Postby Vince|Dyalog on Thu Aug 12, 2021 2:56 pm

Hi Tobias,

Sorry, I think this only works in Link 2.1.

Also, you need to give a full path to beforeRead like this:

options.beforeRead←'#.load.beforeRead'

options ⎕SE.Link.Create 'ws' 'd:/git/test3'

Linked: #.ws ←→ d:\git\test3
load.called
4

Regards,

Vince
Vince|Dyalog
 
Posts: 443
Joined: Wed Oct 01, 2008 9:39 am

Re: How to use ]Link.Create beforeRead hook?

Postby Vince|Dyalog on Thu Aug 12, 2021 3:16 pm

Hi Tobias,

There was a link bug #68 fixed in Link 2.1: Link.Import should call beforeRead for variables

https://github.com/Dyalog/link/issues/68

Although the bug only mentions variables, I think this must be related to beforeRead in general.

Regards,

Vince
Vince|Dyalog
 
Posts: 443
Joined: Wed Oct 01, 2008 9:39 am


Return to Source Code Management

Who is online

Users browsing this forum: No registered users and 1 guest