Skip to content

Latest commit

 

History

History
41 lines (34 loc) · 816 Bytes

fast-loads.md

File metadata and controls

41 lines (34 loc) · 816 Bytes

Fast loads

==TODO: Rewrite for q.==

Loads should take no time.

Suppose you write a script a.k which involves an expensive initialization, say by means of a synchronous request for data from a server:

.A:(`server;1234) 4:(`retrieve;)

You mean to load a.k from within the application b.k, which looks like this:

\l a
\d .B
Show:"`show $ `.A"
Show..c:`button
\d ^
`show $ `B

but now b takes too long to come up.

So now you decide to improve things by having Show load the a script:

Show:".\"\\1 a"

This is wrong. Instead, modify the a script by moving the retrieval code into a function:

\d .a
retrieve:{(`server;1234`) 4:(`retrieve;)}

and changing the definition of Show in b.k:

\l a
\d .B
Show:"`show$.[`.A;();:;.a.retrieve[]]"
…