Repository: latex3/latex3

Issue #1306: Some built-in fp operators are not supported in symbolic expr
Created: 2023-10-26T18:52:14Z
They are:

infix binary comparisons like >, =, <
prefix unary functions like sign and fact
(looks like can be easily added by using \__fp_symbolic_unary_o:NNw)
infix ternary operator like ?:
(currently <expr with var> ? 1 : 2 always gives 1)
prefix variable-ary functions like round and friends, min, max, atan, acot, atand, acotd

l3fp-symbolic.dtx also mentioned this at the end

  
    
      latex3/l3kernel/l3fp-symbolic.dtx
    
    
        Lines 676 to 679
      in
      338de22
    
  
  
    

        
          
           % \subsection{Road-map} 
        

        
          
           % 
        

        
          
           % The following functions are not implemented: |min|, |max|, |?:|, 
        

        
          
           % comparisons, |round|, |atan|, |acot|. 
        
    
  


\documentclass{article}
\ExplSyntaxOn
\cs_new:Npn \test_operators:n #1
  {
    \clist_map_inline:nn { #1 }
      {
        \leavevmode
        \llap { \tl_to_str:n {##1} } \quad => \quad
        \fp_to_tl:n { ##1 } \par
      }
  }
\ExplSyntaxOff

\begin{document}
\ttfamily\frenchspacing

\ExplSyntaxOn
\fp_new_variable:n {a}

% not or illy supported
\test_operators:n
  {
    a ? 1 : 2,
    1 > a,
    {round(a, 3)},
    min(a),
    fact(a),
    sign(a)
  }
\bigskip

\tl_map_inline:nn
  { {fact} {sign} }
  {
    \cs_new:cpe { __fp_symbolic_#1_o:w }
      {
        \exp_not:N \__fp_symbolic_unary_o:NNw
        \exp_not:c { __fp_#1_o:w }
      }
  }

% support just added
\test_operators:n
  { fact(a), sign(a) }

\ExplSyntaxOff
\end{document}

Duplicate issue #1356: `\fp_set_function:nnn` doesn't accept valid expressions
Created: 2023-11-30T13:06:40Z
Consider the following input file
\RequirePackage{latexbug}
\documentclass{article}

\begin{document}

\ExplSyntaxOn

\fp_new_variable:n { a }
\fp_set_variable:nn { a } { 3e-2 }

\fp_eval:n { a>1 } \par

\fp_new_function:n { foo }
\fp_set_function:nnn { foo } { x } { (x>1) }

\fp_eval:n { foo(a) }

\ExplSyntaxOff

\end{document}
This fails at \fp_set_function:nnn
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023) (preloaded format=pdflatex 2023.11.21)  30 NOV 2023 14:03
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**func
(./func.tex
LaTeX2e <2023-11-01>
L3 programming layer <2023-11-09>
(/usr/local/texlive/2023/texmf-dist/tex/latex/latexbug/latexbug.sty
Package: latexbug 2022/06/14 v1.0n Bug-classification
)
(/usr/local/texlive/2023/texmf-dist/tex/latex/base/article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(/usr/local/texlive/2023/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2023/05/17 v1.4n Standard LaTeX file (size option)
)
\c@part=\count186
\c@section=\count187
\c@subsection=\count188
\c@subsubsection=\count189
\c@paragraph=\count190
\c@subparagraph=\count191
\c@figure=\count192
\c@table=\count193
\abovecaptionskip=\skip48
\belowcaptionskip=\skip49
\bibindent=\dimen140
)
(/usr/local/texlive/2023/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def
File: l3backend-pdftex.def 2023-11-09 L3 backend support: PDF output (pdfTeX)
\l__color_backend_stack_int=\count194
\l__pdf_internal_box=\box51
)
(./func.aux)
\openout1 = `func.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for TS1/cmr/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.

! Missing number, treated as zero.
<to be read again> 
                   \__fp_compare_back_symbolic:ww 
l.14 \fp_set_function:nnn { foo } { x } { (x>1) }
                                                 
? q
OK, entering \batchmode...
! Missing number, treated as zero.
<to be read again> 
                   \__fp_compare_back_symbolic:ww 
l.14 \fp_set_function:nnn { foo } { x } { (x>1) }
                                                 
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

)
Runaway argument?
{\exp_after:wN \exp_stop_f: }\s__fp \__fp_chk:w 00\s__fp_exact ;\exp:w \ETC.
! File ended while scanning use of \__fp_exp_after_symbolic_f:nw.
<inserted text> 
                \par 
<*> func^^M
           
I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.

! Emergency stop.
<*> func^^M
           
*** (job aborted, no legal \end found)

 
Here is how much of TeX's memory you used:
 1764 strings out of 474273
 42065 string characters out of 5747713
 1923555 words of memory out of 5000000
 24052 multiletter control sequences out of 15000+600000
 558069 words of font info for 36 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 35i,0n,50p,157b,1309s stack positions out of 10000i,1000n,20000p,200000b,200000s
!  ==> Fatal error occurred, no output PDF file produced!

Closing comment (2023-12-01T09:12:43Z): Duplicate of #1306