ENB: Sweet spots in the new importers

15 views
Skip to first unread message

Edward K. Ream

unread,
May 17, 2023, 8:50:21 AM5/17/23
to leo-editor

This Engineering Notebook post discusses design issues involving balance. 


Importer methods


There is a constant tension between simplicity and generality. The new code generally gets the balance exactly right.


i.delete_comments_and_strings: Leo's per-language settings tell this method about comments and strings. Perfection!


i.find_blocks: Importers define two overrides. Today's Aha about validating potential blocks may make the overrides unnecessary.


i.find_end_of_block: Importers define three overrides. All seem necessary.


i.__init__: Recent revs have removed almost all ivars. It may be possible to eliminate this ctor! Doing so would have happy ripple effects.


Pattern matching


i.find_blocks matches regex patterns line by line. As a result, wildcard matches such as *.? have no performance issues. Patterns suggest candidate matches. c_i.find_end_of_block will validate those candidates with a simple scanner.


Summary


The new importers have found the sweet spot between simplicity and generality. In most cases, simplicity creates generality.


Finding candidate matches line-by-line prevents performance bugs while allowing arbitrarily complex function signatures.


Balance is uppermost in my mind as I complete Leo's importers. I have a rare opportunity to create perfection!


Edward

Edward K. Ream

unread,
May 17, 2023, 10:19:47 AM5/17/23
to leo-editor
On Wednesday, May 17, 2023 at 7:50:21 AM UTC-5 Edward K. Ream wrote:

i.__init__: ...It may be possible to eliminate this ctor!


Not likely. self.c will always be required. But everything else can probably go. In fact, the Importer class is already stateless.

Edward
Reply all
Reply to author
Forward
0 new messages