IRC channel logs

2024-09-18.log

back to list of logs

<cpli>how much work would it be to add more number representations to the numerical tower? is it "built" in a way where it would extensively accept more?
<cpli>i was thinking of implementing polar? complex? numbers and give the existing primitive: cartesian?. i've been playing around with 128-bit complex representation with double magnitude and two single float angle values: (atan2 (sin θ) (cos θ)), which would essentially give double,double polar form precision
<cpli>the same would apply to 64-bit f32,(f16,f16) floats..
<adhoc>is there an SFRI for that ?
<adhoc> https://www.gnu.org/software/guile/manual/html_node/SRFI-Support.html
<adhoc>upstream SRFI libraries for scheme; https://srfi.schemers.org/
<cpli>there don't seem to be any srfi for additional numbers, maybe i should rfi: exact complex, polar, and algebraic numbers..
<adhoc>cpli: I do remember reading about it in one of those a while back.
<adhoc>or maybe it was in some thing from the Racket folks.
<adhoc>cpli: is this the kind of thing you can write entirely in scheme?
<cpli>asides from inexact polar forms, yes
<cpli>as in, flonum complex polar forms wouldn't have hardware support, which is kind of horrendeous *if* one was to write it entirely in scheme
<adhoc>but then it would be portable.
<adhoc>and would benifit the wider scheme community
<adhoc>and with enough demand, hardware support could be easier to argue for =)
<ArneBab>cwebber: GraalVM (Java with native compilation) now supports Wasm-Applications, so does that mean Guile with Hoot can run on the GraalVM? /end heretic ☺
<graywolf>Hello Guile users :) Quick question, I was searching for naming conventions on scheme (well, guile in particular). I get the ? (predicate), ! (side-effects, usually modifying the operands) and * (similar but not same). What I am unsure about is leading %. When exactly do people use it?
<graywolf>Some stackoverflow post also mentioned *variable* and +constant+, any opinions there?
<dthompson>% is generally used for private names
<graywolf>But private are just un-exported no?
<graywolf>Or is it even for exported but "careful when touching this"?
<dthompson>it's used to mark more low-level implementation detail things, generally
<dthompson>like you might define a record type with a constructor %make-foo and then write a wrapper make-foo that is the public constructor
<graywolf>I think I understand, thanks :)
<graywolf>By any chance any opinion on *variable* and +constant+? I think I did not see that in guile code (yet), but it is referenced on the interwebs as a naming scheme that is used as well
<cwebber>ArneBab: hm maybe! depends on what wasm extensions they support
<dpk>cpli: Scheme already has polar complexes, but they’re not represented distinctly from cartesian complexes
<dpk>see the make-polar, magnitude, and angle procedures
<dpk>alas, because they’re not represented distinctly from rectangular complexes, there are no exact polar complexes: the arguments to make-polar get fed through the trigonometric functions to convert them to positions in the rectangular plane
<dpk>even exact rectangular complexes are controversial enough, though. i don’t use complexes enough to have an opinion on the matter, but R6RS and R7RS Large did end up deciding to require them
<dthompson>guile represents complex numbers using 2 doubles
<dthompson>hoot does the same
<dpk>you also cannot extend the numeric tower in any standardized way, and in fact i’m not aware of any implementation supporting it either
<dpk>we’ve talked a bit about it. some people want quaternions
<dpk>i would quite like units a la DSSSL
<dthompson>in a way it's odd that scheme is generally very monomorphic... except for numbers
<dpk>neither of those are pressing enough to be standardized any time soon, but nonetheless it would be nice to have a way to add them other than defining your own arithmetic procedures
<dthompson>I most commonly use 2d/3d vectors and 4x4 matrices as additional data types for math
<dthompson>but I have no problem with writing my own monomorphic procedures for these as I often don't want to pay the overhead of generic dispatch
<dthompson>thankfully you can just add your own generic dispatch on top, like GOOPS or the various iterations in Sussman's books
<dpk>(i also wanted a define-immediate-type which you could invoke maybe up to 256 times within the same running system, that would give you a disjoint type with a 48-bit bitfield to play with, without stressing the allocator. that would be useful for some arithmetic extensions. that’s definitely not going to happen in R7RS Large but i would really like an implementation to play around with supporting it!)
<dpk>dthompson: the point of the numeric tower is that ‘number’ is one type; we take a mathematical, not representational view of arithmetic
<dthompson>yeah I get it but it's a pain to deal with :)
<dthompson>need a good compiler to make the maths go brrr
<dthompson>thankfully guile is quite good at it now
<dpk>there’s also the assumption if you want fast arithmetic that you are working with IEEE doubles (flonums) or with integers at most 24 bits wide (portable fixnums; most implementations support more, but R6RS requires at least 24)
<dpk>it’s the same problem people complained at Common Lisp about, 30 or 40 years ago :D
<dpk> (https://www.dreamsongs.com/Files/clcrit.pdf)
<mwette>what about "long double" or f128 (which may be 96 bits)
<dpk>mwette: implementations are allowed, but not required, to support up to four precisions of inexacts (short, single, double, long, see R7-small p. 34 right hand column near the bottom)
<dpk>in practice, i’m not sure anyone does; Racket BC was, iirc, one of the few implementations to support both IEEE singles and doubles
<dpk>R7-small doesn’t even say that inexacts will be IEEE 754, nor that they will be floats (they might be fixed point)
<dpk>even if you did have four precisions, nobody’s telling how long each one actually is