guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Screaming-Fist: a JIT framework for Guile


From: Maxime Devos
Subject: Re: Screaming-Fist: a JIT framework for Guile
Date: Mon, 4 Dec 2023 22:26:37 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0



Op 03-12-2023 om 18:26 schreef Nala Ginrut:
(jit-define (square x)
   (:anno: (int) -> int)
   (* x x))
(square 5)


Potentially-overflowing arithmetic involving ints (not unsigned ints, but ints)? Best document somewhere to what the jit code '(* x x)' evaluates when (not (<= min-int (* x x) max-int))).

Personally, I'm in favor of explicit long names like

*/error-on-overflow (<-- maybe on the C-level the function could return a tagged union representing (failure [no value]) / (success [some value], at a slight performance cost)
*/wrap-around
*/undefined-on-overflow (<-- like in C, for maximal performance and dragons).

(Likewise for +, - and unsigned int)

Sure, they are a bit verbose, but they are explicit and non-explicitness+undefined behaviour of'*' in C has caused serious issues in the past, so I'd think it's better that the programmer has to choose what, in their situation, are the appropriate semantics.

If/when someone desired shorter names, there could be a
(jit-define-alias * */wrap-around) or something like that for that?

Best regards,
Maxime Devos

Attachment: OpenPGP_0x49E3EE22191725EE.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]