I am using a properties list and I would like to be able to create a command that produces the list of keys to be used to generate a for loop. I am currently using \prop_map_inline to generate all the keys but if I use this in the for loop it is interpreted as a single item and not a collection of several items.
This is an example code:
\documentclass{article}
\usepackage{ifthen}
\usepackage{xparse}
\ExplSyntaxOn
\prop_new:N \g_persons_prop
% Create a new person
\NewDocumentCommand{\CreatePerson}{m} {
\prop_gput:Nnn \g_persons_prop { #1 }
}
% Gets all persons
\NewDocumentCommand{\GetAllPersonKeys}{}{
\prop_map_inline:Nn \g_persons_prop {
##1,
}
}
\ExplSyntaxOff
\CreatePerson{jd}{John Doe}
\CreatePerson{ad}{Albert Dull}
\CreatePerson{bu}{Ben Under}
\begin{document}
I would like to have this:
\makeatletter
\begin{itemize}
@for\sun:={jd, ad, bu}\do{\item We have person: \sun. }
\end{itemize}
\makeatother
But I get this instead:
\makeatletter
\begin{itemize}
\@for\sun:={\GetAllPersonKeys}\do{\item We have person: \sun. }
\end{itemize}
\makeatother
\end{document}


CreatePersonto take? – user202729 May 10 '22 at 14:59prop_map_inline ... {We have person: ...}? – user202729 May 10 '22 at 15:01GetAllPersonKeysas implemented as not expandable, and • you didn't even try to expand it before executing@for, so no guarantee. – user202729 May 10 '22 at 15:03\@forf-expand the argument. So you have to use something f-expandable, such as\use:e's\expandedemulation plus some otherprop_mapfunction that is hollow-star. Try it yourself, if\tl_show:f {\GetAllPersonKeys}shows the correct comma-separated result you know it's correct. – user202729 May 10 '22 at 15:32\GetAllPersonKeys \@for \sun :={\AllPersonKeysResult} \do {...}it would be much easier to implement. – user202729 May 10 '22 at 15:33\GetAllPersonKeys \@for \sun :={\AllPersonKeysResult} \do {...}does what you want, but you need the initial\GetAllPersonKeysto be outside. If you're happy with that the answer would be simpler. – user202729 May 10 '22 at 16:49