On Mon, May 4, 2020 at 2:56 PM vitalije <[email protected]> wrote: I didn't like it either. But I don't think that it is possible to solve > this purely using decorator functions. >
I agree. On my walk today I saw things in a new light. The first comment of #325 starts with: "I want to replace @cmd decorators by by @g.command decorators everywhere, thereby eliminating g.cmd_instance_dict, which is unbearably ugly." There are two problems with this statement. First, using @g.command decorators everywhere can be clumsy, as the new code in the commands branch makes clear. The virtue of @cmd is that it puts the decorator next to the code that should be decorated. Using @g.command everywhere is one step forward (simplicity) and one step back (added remoteness). Second, g.cmd_instance_dict is not, in fact, unbearably ugly. In some ways it's clever and descriptive. Indeed, the only thing the @cmd descriptors know is c. The dict allows per-class cmd descriptors to use the chain of ivars to recover the instance of the desired class. *Summary* I now think that Leo's code base is good as it is. There is no great need to use @g.command. Instead, it makes sense to use @cmd to decorate methods and @g.command to decorate functions. In other words, #325 can be retired, after making clear that: 1. g.cmd_instance_dict is a reasonable solution to a very difficult problem, 2. There is a place for both the @cmd and @g.command decorators. I am willing to abandon all the work I have done in the command branch. I have enjoyed working on the script that created top-level commands using @g.command. It's good code in the service of a what seems now to be a dubious goal. Looking forward, the script is a model for analyzing and changing code. We can keep this model in mind as we consider even more ambitious changes to Leo's code. Vitalije, I thank you for your work on @g.command. It has convinced me that all solutions to the stated problem will be difficult. 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/CAMF8tS3maFafY9F5gdUdndPeEY_iQj1vUtDF%3DAP5uZFnA8TiTg%40mail.gmail.com.
