Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Fwd: more splitting travails



On Sat, Jan 13, 2024 at 5:55 AM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> Well, Roman will be glad to hear that I was just about to do a typeset -p on both versions to see the difference.
>
> 0 /aWorking/Zsh/Source/Wk 0 % typeset -p vvar
> typeset -a vvar=( 'one two' three '' four '' 'five six seven' '' '' eight )
>
> 0 /aWorking/Zsh/Source/Wk 0 % typeset -p aaa
> typeset aaa=$'one two\nthree\n\nfour\n\nfive six seven\n\n\neight'
>
> I won't forget again.

I *am* glad.

Whenever I start  learning a new programming language, the very first
thing I always research is how to do "printf debugging" in it. This is
what the technique of inserting manual instrumentation in your code is
called. If you know how to printf debug, you can see what your
programs do, which in turn allows you to understand the programming
language by experimentation.

So, `typeset -p` isn't just one of the multitude of tricks that zsh
practitioners have in their toolbox. It's not in the same category as
"how to read the full content of a file" or "how to generate a secure
random number". No, it's a meta tool that lets you understand your own
code. You absolutely must remember it.

Roman.




Messages sorted by: Reverse Date, Date, Thread, Author