trip logs / gnuvola


Trip Log 2021-12-31 h09 -- Indices Style Upgrade Part 8

Welcome back to another trip log in the Indices Style Upgrade series.  In this episode, we cover patch 6, no more no less.  (Feel free to grab the accompanying tarball and follow along.)  Let's go! 

In the previous trip log we touched upon alias ‘oldest-first’.  Well, like many aspects of life, the old must cede to the young at times.  So it is with our friend ‘oldest-first’.  Here's the excerpt, for your convenience: 

 4	Subject: [PATCH 6/8] tl-mkindex: Order trip log entries youngest first.
[...]
 9	* sub/tl-mkindex (youngest-first): New proc.
10	(oldest-first): Delete proc alias.
11	(consult-db one): Use ‘youngest-first’.
12	(interesting-elements): Likewise.
[...]
21	@@ -214,11 +214,12 @@ (define (sort/car bef ls)
22	              (bef (car a)
23	                   (car b)))))
24
25	+(define (youngest-first ls)
26	+  (sort/car string>? ls))
27	+
28	 (define (lexicographically-ordered ls)
29	   (sort/car string<? ls))
30
31	-(define oldest-first lexicographically-ordered)
32	-
33	 (define (consult-db upath-ignored where-clause)
34
35	   ;; Aside from the "lift" comment below, it would be nice to be
36	@@ -254,7 +255,7 @@ (define (consult-db upath-ignored where-clause)
37	                       *text)))))
38
39	   (define (one tag upath title)
40	-    (cons tag (oldest-first (map cons upath title))))
41	+    (cons tag (youngest-first (map cons upath title))))
42
43	   (lexicographically-ordered
44	    (apply map one (cols<-tuples-result
45	@@ -287,7 +288,7 @@ (define (interesting-elements)
46
47	   (let-values (((leaf? tag refs) (context)))
48	     (let* ((distinct-refs (delete-duplicates
49	-                           (oldest-first (apply append refs))))
50	+                           (youngest-first (apply append refs))))
51	            (url (map car distinct-refs)))
52
53	       (define (leaf-entries)
54	--

As hinted by the patch title (line 4) and the none-too-subtle description (line 10), the whole point of the patch is to look at things from a ‘yougest-first’ perspective.  All the interesting stuff happens in hunk 1; hunks 2 and 3 are simply updates. 

What we see is that, at its heart, the difference between ‘oldest-first’ and ‘youngest-first’ is the choice of 1st arg to ‘sort/car’.  For ‘oldest-first’ (actually, its alias target ‘lexicographically-ordered’), that choice was ‘string<?’, a predicate favoring the long-winded, while for ‘youngest-first’, that choice is ‘string>?’, favoring the ascendent might of the not-yet-tired crowd.  :-D 

Thus, this patch makes a user-visible change: It shows the most recent entries first.  That's the style these days, the young piling on top of the old.  Stepping back, we see that patch 5 set up ‘oldest-first’ to be the fall guy for patch 6.  One can only hope the treatment to be judged as graceful and dignified. 


Copyright (C) 2021 Thien-Thi Nguyen