My Sherlock product predated Leo by several years. It was a commercial and 
practical failure. Yesterday, I removed the SherlockTracer class from Leo:


- It likely did not work with recent Python versions.

- It was way too slow.

- It was overly complex in concept.


This Engineering Notebook post discusses what I *wanted* Sherlock to do and 
discusses various alternatives.


*Exploring dynamic data*


We programmers write static text, but our programs deal with dynamically 
generated data. I've often wanted better tools to study the data that flows 
through our programs.


I've been studying mypy recently. I created a small test file to help me in 
my studies.


A cff shows that mypy contains 111 methods named "accept"! I want to know 
which ones mypy calls when handling the test file. Single-stepping through 
the code would be tedious and error-prone. The code is just too complicated.


A Sherlock-like idea would be add trace statements to all the "accept" 
methods. Leo issue #3562 
<https://github.com/leo-editor/leo-editor/issues/3562> suggests writing a 
script to insert these traces.


Preliminary work showed that Leo's Python importer can help discover the 
desired code reliably. It's a clever idea. The script analyzes *guide lines* 
just 
as the importer does.


But on second thought, the script seems like an overly complicated solution 
to what should be a straightforward problem—just like Sherlock was. 
Instead, I could use a cff to find all the nodes containing "def accept." A 
simple regex will then place the cursor the "def" lines. I can then insert 
the desired traces manually or with a regex replace.


A problem arises that a script might help solve. *Leo's searches know 
nothing about p.h!* That's a pity because headlines contain valuable 
context.


Suppose we allow replacement text to contain an Easter Egg, say {p.h}. This 
convention would *not* execute code; it would simply be a marker indicating 
that p.h should be part of the replacement text.


*Summary*


I rarely want to insert many tracing or debugging statements. When I do, 
neither Sherlock nor similar scripting helpers will help much.


Instead, a cff followed by a regex search/replace will work. Such searches 
might be clumsy, especially when the replacement text is variable.


We might consider adding an Easter Egg: in replacement patterns {{p.h}} 
would insert p.h into the replacement text *without* executing any code. 


I'll try adding traces manually to see how clumsy that would be. I'll also 
continue working on #3562 
<https://github.com/leo-editor/leo-editor/issues/3562> to see where it 
leads. However, I suspect it is a dead end.  


All of your comments are welcome.


Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/eec2388a-bc0f-4202-818e-1194d7a88f04n%40googlegroups.com.

Reply via email to