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

Re: PATCH: user-defined math functions



Barton Schaefer wrote:
> Use typeset?  Currently I think the -i/-E/-F options cannot be combined 
> with -f.  Allow them to be, and have them create math functions with the 
> corresponding return types.

I'm not convinced that gains you much...  Overloading typeset doesn't
make for a very clear interface, which is presumably why autoload +/-X
are seperate and not done via typeset -fu (= functions -u).

As currently written, the return value is self-typing, since (( 1 )) and
(( 1.0 )) are represented by different members of a discriminated union.
Coercing the return value to integer or floating point via the interface
rather than the implementation function therefore doesn't seem to me to
gain much, either.

Since it's the value that's important, not the representation -E and -F
numbers are equivalent at this point.  (It's a bit different at when
calling the function because of the array problem, but it still uses as
many floating point digits as it can to reduce the effect of
truncation.)  Further, since the functions are only used within an
expression, the output representation wouldn't be used at the point
where the function's value is.

I think I'll just commit what I've currently got...  I've tweaked a few
tests for safety in functions -M as well as the documentation.

Mixed in with the patch are some tweaks I made to add some styles to
pick-web-browser which aren't likely to be of earth-shattering general
interest.

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page still at http://www.pwstephenson.fsnet.co.uk/



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