memoize adjustments #6

Closed
opened 2026-03-24 11:48:17 +00:00 by lukas · 8 comments
Owner
  • add counter to context
  • blank externs? -> yes this are the phantoms
  • add everything to context
  • make use of memoize optional
- [x] add counter to context - [x] blank externs? -> yes this are the `phantom`s - [x] add everything to context - [x] make use of memoize optional
lukas self-assigned this 2026-03-24 11:48:17 +00:00
Author
Owner
https://github.com/atticus-sullivan/kata/pull/2/changes/5d1c42b978e8ceea7ef4345083cfe1b0493d9ca2
Author
Owner
see also https://github.com/atticus-sullivan/kata/issues/1#issuecomment-4137613656
Author
Owner

Reproducing the hashes:

  • content
    $ cat tex-aux/main.D137D1D39F130D42A0D9BF91252C92C3.memo | tr -d "\n" | md5sum
    d137d1d39f130d42a0d9bf91252c92c3  -
    
  • context
    $ cat tex-aux/main.D137D1D39F130D42A0D9BF91252C92C3-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.memo | tr -d "\n" | md5sum
    e778dcccb8aab0bbd3f6cfeefd2421f8  -
    

(tr only to remove the final \n and the files were previously stripped to only contain the content/context)

\mmzResource{main.D137D1D39F130D42A0D9BF91252C92C3-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.pdf}%
\mmzMemo 
\quitvmode \mmzIncludeExtern {0}\hbox {88.52792pt}{6.94444pt}{0.0pt}{72.26999pt}{72.26999pt}{72.26999pt}{72.26999pt}%
\mmzThisContext 
padding=(1in,1in,1in,1in), % <- ONLY kept this line
\mmzEndMemo 
\mmzMemo 
\global \mmzContextExtra {}%
%
\mmzSource 
Extern A: \foo [abc] % <- ONLY kept this line
Reproducing the hashes: - content ```bash $ cat tex-aux/main.D137D1D39F130D42A0D9BF91252C92C3.memo | tr -d "\n" | md5sum d137d1d39f130d42a0d9bf91252c92c3 - ``` - context ```bash $ cat tex-aux/main.D137D1D39F130D42A0D9BF91252C92C3-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.memo | tr -d "\n" | md5sum e778dcccb8aab0bbd3f6cfeefd2421f8 - ``` (`tr` only to remove the final `\n` and the files were previously stripped to only contain the content/context) ```tex \mmzResource{main.D137D1D39F130D42A0D9BF91252C92C3-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.pdf}% \mmzMemo \quitvmode \mmzIncludeExtern {0}\hbox {88.52792pt}{6.94444pt}{0.0pt}{72.26999pt}{72.26999pt}{72.26999pt}{72.26999pt}% \mmzThisContext padding=(1in,1in,1in,1in), % <- ONLY kept this line \mmzEndMemo ``` ```tex \mmzMemo \global \mmzContextExtra {}% % \mmzSource Extern A: \foo [abc] % <- ONLY kept this line ```
Author
Owner

Also look at the following example:

\documentclass[a4paper]{article}

\usepackage{memoize}
\mmzset{include context in ccmemo,trace}

\def\fooA{Hello}
\def\fooB{World}

\NewDocumentCommand{\foo}{o}{
	\IfBlankTF{#1}{
		\fooA
	}{
		\fooB
	}
}

\mmzset{
	auto=\fooB{to context},
	auto=\fooA{to context},
}

\begin{document}

\begin{memoize}
	Extern A: \foo[abc]
\end{memoize}

\end{document}

Gets the following memo:

% tex-aux/main.D137D1D39F130D42A0D9BF91252C92C3-0AB0D68CB700684CE9DE27E445F9C403.memo
\mmzResource{main.D137D1D39F130D42A0D9BF91252C92C3-0AB0D68CB700684CE9DE27E445F9C403.pdf}%
\mmzMemo
\quitvmode \mmzIncludeExtern {0}\hbox {83.52791pt}{6.94444pt}{0.0pt}{72.26999pt}{72.26999pt}{72.26999pt}{72.26999pt}%
\mmzThisContext
padding=(1in,1in,1in,1in),original "/mmz" csname "fooB"={macro:->World},
\mmzEndMemo

Changing World to World3 it becomes:

% tex-aux/main.D137D1D39F130D42A0D9BF91252C92C3-CEF27CF1F5354793D6C7EC8EB23FD32E.memo
\mmzResource{main.D137D1D39F130D42A0D9BF91252C92C3-CEF27CF1F5354793D6C7EC8EB23FD32E.pdf}%
\mmzMemo
\quitvmode \mmzIncludeExtern {0}\hbox {88.52792pt}{6.94444pt}{0.0pt}{72.26999pt}{72.26999pt}{72.26999pt}{72.26999pt}%
\mmzThisContext
padding=(1in,1in,1in,1in),original "/mmz" csname "fooB"={macro:->World3},
\mmzEndMemo

and it does not change when only changing Hello

Also look at the following example: ```tex \documentclass[a4paper]{article} \usepackage{memoize} \mmzset{include context in ccmemo,trace} \def\fooA{Hello} \def\fooB{World} \NewDocumentCommand{\foo}{o}{ \IfBlankTF{#1}{ \fooA }{ \fooB } } \mmzset{ auto=\fooB{to context}, auto=\fooA{to context}, } \begin{document} \begin{memoize} Extern A: \foo[abc] \end{memoize} \end{document} ``` Gets the following `memo`: ```tex % tex-aux/main.D137D1D39F130D42A0D9BF91252C92C3-0AB0D68CB700684CE9DE27E445F9C403.memo \mmzResource{main.D137D1D39F130D42A0D9BF91252C92C3-0AB0D68CB700684CE9DE27E445F9C403.pdf}% \mmzMemo \quitvmode \mmzIncludeExtern {0}\hbox {83.52791pt}{6.94444pt}{0.0pt}{72.26999pt}{72.26999pt}{72.26999pt}{72.26999pt}% \mmzThisContext padding=(1in,1in,1in,1in),original "/mmz" csname "fooB"={macro:->World}, \mmzEndMemo ``` Changing `World` to `World3` it becomes: ```tex % tex-aux/main.D137D1D39F130D42A0D9BF91252C92C3-CEF27CF1F5354793D6C7EC8EB23FD32E.memo \mmzResource{main.D137D1D39F130D42A0D9BF91252C92C3-CEF27CF1F5354793D6C7EC8EB23FD32E.pdf}% \mmzMemo \quitvmode \mmzIncludeExtern {0}\hbox {88.52792pt}{6.94444pt}{0.0pt}{72.26999pt}{72.26999pt}{72.26999pt}{72.26999pt}% \mmzThisContext padding=(1in,1in,1in,1in),original "/mmz" csname "fooB"={macro:->World3}, \mmzEndMemo ``` and it does not change when only changing `Hello` ✅
Author
Owner

I'm just a bit confused why the to context key then is colored in red (Red
background indicates other, more or less advanced keys and commands
) if it is so natural using it.

On the other side what is the use of meaning to context? Why add something to the context when it's not used?

I'm just a bit confused why the `to context` key then is colored in `red` (*Red background indicates other, more or less advanced keys and commands*) if it is so natural using it. On the other side what is the use of `meaning to context`? Why add something to the context when it's not used?
Author
Owner

Styles which add to context:

Style Adds to context Used when drawing
/kata/style/head (kataStep -> \kata@head)
/kata/style/stance (\kataStance)
/kata/style/waza (\kataWaza)
/kata/style/dir (\kataDir)
/kata/style/border (kataStep)
/kata/style/step counter (kataStep)
/kata/style/stance label base (stance label[ flipped])
/kata/style/stance label (\kataStance)
/kata/style/stance label flipped (\kataStance)
/kata/style/waza label base (waza label[ flipped])
/kata/style/waza label (\kataWaza)
/kata/style/waza label flipped (\kataWaza)
/kata/style/step phantom (kata)

Additionally:

  • package version
  • kataStepCnt -> formatter
  • counter kata@step

Todo:

  • check if * label base is even required to add to the context
Styles which add to context: | Style | Adds to context | Used when drawing | | --------- | --------- | --------- | | `/kata/style/head` | ✅ | ✅ (`kataStep` -> `\kata@head`) | | `/kata/style/stance` | ✅ | ✅ (`\kataStance`) | | `/kata/style/waza` | ✅ | ✅ (`\kataWaza`) | | `/kata/style/dir` | ✅ | ✅ (`\kataDir`) | | `/kata/style/border` | ✅ | ✅ (`kataStep`) | | `/kata/style/step counter` | ✅ | ✅ (`kataStep`) | | `/kata/style/stance label base` | ✅ | ✅ (`stance label[ flipped]`) | | `/kata/style/stance label` | ✅ | ✅ (`\kataStance`) | | `/kata/style/stance label flipped` | ✅ | ✅ (`\kataStance`) | | `/kata/style/waza label base` | ✅ | ✅ (`waza label[ flipped]`) | | `/kata/style/waza label` | ✅ | ✅ (`\kataWaza`) | | `/kata/style/waza label flipped` | ✅ | ✅ (`\kataWaza`) | | `/kata/style/step phantom` | ✅ | ✅ (`kata`) | | ` ` | | | Additionally: - package version - `kataStepCnt` -> formatter - counter `kata@step` Todo: - [x] check if `* label base` is even required to add to the context
Author
Owner
\documentclass[a4paper]{article}

\usepackage{memoize}
\mmzset{include context in ccmemo,trace}
\usepackage{tikz}

\NewDocumentCommand{\foo}{}{
	\tikzset{/test/foo}
	Hello World
}
\pgfkeys{
	/test/.cd,
	/test/fooA/.style={blue},
	/test/foo/.style={
		/test/foo/.meaning to context,
		draw,
		/test/fooA
	},
}
\mmzset{auto=\foo{memoize,args={}}}

\begin{document}
\foo
\end{document}

produces the following context:

\mmzResource{main.B6D05BCAB87249D41C009B1651AB648F-8363B93CBF071EF9B6D153C8C3AEA681.pdf}%
\mmzMemo
\quitvmode \mmzIncludeExtern {0}\hbox {62.52786pt}{6.94444pt}{0.0pt}{72.26999pt}{72.26999pt}{72.26999pt}{72.26999pt}\mmzStepPgfPictureId {0}%
\mmzThisContext
padding=(1in,1in,1in,1in),pgfk@/test/foo/.@cmd={\long macro:#1\pgfeov ->\pgfkeysalso {/test/foo/.meaning to context, draw, /test/fooA}},
\mmzEndMemo

so the context contains /test/fooA literally and does not resolve it -> *label base must add to the context

```tex \documentclass[a4paper]{article} \usepackage{memoize} \mmzset{include context in ccmemo,trace} \usepackage{tikz} \NewDocumentCommand{\foo}{}{ \tikzset{/test/foo} Hello World } \pgfkeys{ /test/.cd, /test/fooA/.style={blue}, /test/foo/.style={ /test/foo/.meaning to context, draw, /test/fooA }, } \mmzset{auto=\foo{memoize,args={}}} \begin{document} \foo \end{document} ``` produces the following context: ``` \mmzResource{main.B6D05BCAB87249D41C009B1651AB648F-8363B93CBF071EF9B6D153C8C3AEA681.pdf}% \mmzMemo \quitvmode \mmzIncludeExtern {0}\hbox {62.52786pt}{6.94444pt}{0.0pt}{72.26999pt}{72.26999pt}{72.26999pt}{72.26999pt}\mmzStepPgfPictureId {0}% \mmzThisContext padding=(1in,1in,1in,1in),pgfk@/test/foo/.@cmd={\long macro:#1\pgfeov ->\pgfkeysalso {/test/foo/.meaning to context, draw, /test/fooA}}, \mmzEndMemo ``` so the context contains `/test/fooA` literally and does not resolve it -> **`*label base` must add to the context**
lukas added reference feat-memoize 2026-03-30 11:14:41 +00:00
Author
Owner

see #21

see #21
lukas closed this issue 2026-04-01 10:40:35 +00:00
lukas added this to the 1.0.0 milestone 2026-04-12 09:42:26 +00:00
Sign in to join this conversation.
No description provided.