sed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: proposed features for branching logic + minimal implementation


From: Nora Platiel
Subject: Re: proposed features for branching logic + minimal implementation
Date: Tue, 13 Oct 2020 19:38:56 +0200

> At first scan, especially focusing on possible code paths, encountering
> 'Tn' causes me to look for the 'n' label in order to understand where it's
> going... and in a sense, 's/^//;Tn' lies about that. Hence, "put the label
> next to it" became my preferred tactic.

I was suggesting the use of 's/^//;T;', not 's/^//;Tn;', since you mentioned 
"hunting around the keyboard for label names". But you may still find ':n;tn;' 
easier to read.

I agree that both ':n;tn;' and 's/^//;T;' are kludgy and ugly, and I wouldn't 
want to use them. Under this proposal you could also use '@{}' (empty group of 
commands) to reset the flag.

To summarize (correct me if I got something wrong):

@{...}          -> TL; ...; :L
@!{...}         -> tL; ...; :L
k               -> tL;s/^//;:L
j = J;k = @{};k -> s/^//
J = j;k = @{}   -> :L;tL = s/^//;T

The @ address makes more sense to me than the t/T commands themselves: an 
address is a more natural and expressive way to test for a condition.
Under this proposal, t/T would become syntactic sugar:
t -> @b
T -> @!b

More importantly, the single forward branch pattern comes up often enough in my 
scripts, and the @ address would greatly improve readability and simplify label 
management.
+1 for the @ address!

About J/j/k, I'm not sure how useful they are for general purposes, I would 
have to experiment. Perhaps the maintainers would like to see some concrete 
real world example for J/j/k.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]