Hi,

On 15. 12. 19 2:57, Jack Firth wrote:
> I think that documentation fix is a good idea.

I'll submit a PR to appropriate repository later on.

> More broadly, it seems awkward that all of the unsafe ops for 
> different data types are combined together into a single module. I 
> would instead expect there to be modules like racket/fixnum/unsafe, 
> racket/struct/unsafe, racket/vector/unsafe, etc. But I've never used 
> the unsafe ops before, maybe those who have can chime in?

it's not that easy as it is really about the "ops" part. For example if
you need (make-fxvector ...), you still need to require it using
(only-in racket/fixnum make-fxvector) as there is no racket/unsafe/ops
equivalent (which is really NOT surprising).

And also splitting the racket/unsafe/ops into more modules might break a
thing or two as it has been this way for quite some time. Also it is
nice - if you are in need of heavy optimizations - to see the list of
unsafe ops in one place.


Cheers,
Dominik

> 
> On Saturday, December 14, 2019 at 1:03:14 PM UTC-8, Dominik Pantůček 
> wrote:
> 
> Hello,
> 
> the documentation at 
> https://docs.racket-lang.org/reference/fixnums.html 
> <https://docs.racket-lang.org/reference/fixnums.html> is misleading 
> at best. If you - as I did - use the suggested approach of requiring 
> optimized (and unsafe) fx... operations from racket/unsafe/ops with:
> 
> (require (filtered-in (λ (name) (regexp-replace #rx"unsafe-" name 
> "")) racket/unsafe/ops))
> 
> You end up using _all_ symbols from racket/unsafe/ops. All of them 
> are - of course - uncontracted. Which means that if you issue for 
> example vector-ref on something that is not a vector, it can crash 
> the runtime without any apparent reason - instead of just throwing
> an exception as one would expect.
> 
> A simple documentation fix should probably go along the lines:
> 
> (require racket/require (filtered-in (λ (name) (and (regexp-match 
> #rx"^unsafe-fx" name) (regexp-replace #rx"unsafe-" name ""))) 
> racket/unsafe/ops))
> 
> Or is it just me running into corner cases with optimized Racket 
> code?
> 
> 
> Cheers, Dominik
> 
> -- You received this message because you are subscribed to the Google
> Groups "Racket Users" group. To unsubscribe from this group and stop
> receiving emails from it, send an email to 
> [email protected] 
> <mailto:[email protected]>. To view this 
> discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/c118c47e-fccd-4fab-b252-7a24afe6eef1%40googlegroups.com
>
>
>
>
> 
<https://groups.google.com/d/msgid/racket-users/c118c47e-fccd-4fab-b252-7a24afe6eef1%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/4185c1c1-7e2b-ea02-a9c5-03231cb112c2%40trustica.cz.

Reply via email to