On Sat, Oct 14, 2023 at 01:49:26PM -0700, Per Bothner wrote: > On 10/14/23 09:12, Patrice Dumas wrote: > > On Thu, Oct 12, 2023 at 10:25:23AM -0700, Per Bothner wrote: > > > C++ has a more extensive and useful standard library than C. > > > > I guess there is an hash map, but I am not sure that we would need much > > more. > > In addition to hash maps and maybe some other container classes, > I suggest using C++ std::string as being safer and more convenient that C > strings. > > > I am not a good judge, but it is unclear to me that the rewriting in > > perl was a mistake, it allowed to have the current design, which I > > believe is much better than the design of makeinfo in C had. It is > > easier to redesign in a high level language and then translate the parts > > than need to be sped up to a low level language than do everything in a > > low level language. > > I think C++ is about as high-level as Perl, and I think you can > write programs that as similarly concise and legible. > My hunch is that tp/Texinfo written in C++ would be at most a small amount > (20% ?) > more verbose, and to many (including myself) it would be much more readable.
A language that has an "optional chaining" operator would make some texi2any code much more concise: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining https://en.wikipedia.org/wiki/Safe_navigation_operator texi2any is full of code like this: if ($target_element->{'extra'} and $target_element->{'extra'}->{'unit_command'}) { if ($target_element->{'extra'}->{'unit_command'}->{'cmdname'} eq 'node') { $command = $target_element->{'extra'}->{'unit_command'}; } elsif ($target_element->{'extra'}->{'unit_command'}->{'extra'} and $target_element->{'extra'}->{'unit_command'} ->{'extra'}->{'associated_node'}) { $command = $target_element->{'extra'}->{'unit_command'} ->{'extra'}->{'associated_node'}; } } It would be much nicer if it looked like this (imaginary PL syntax): if (target_element.extra?.unit_command?.cmdname eq 'node') { command = target_element.extra.unit_command } elsif (target_element.extra?.unit_command?.extra?.associated_node) { command = target_element.extra?.unit_command?.extra?.associated_node } The closest thing to this is JavaScript AFAIK. However, rewriting texi2any from Perl to JavaScript would be a huge undertaking that would offer no value for the end user.