Re: TR warning with pict3d-canvas% (in pict3d)

Ben Greenman <[email protected]>
Newsgroups gmane.comp.lang.racket.user,gmane.lisp.scheme.plt
Message-ID <CAFUu9R4+3vD6v-7pMwRL8mGHROn2_Q0uuJ5csTKnU87GF-Sw1w@mail.gmail.com>
On Wed, Sep 7, 2016 at 10:35 AM, Tim Brown <[email protected]> wrote:

> ffi-types.rkt:19 is:
>  ..
>  17  (require/typed
>  18   ffi/unsafe
> *19   [#:opaque CPointer cpointer?]  ; includes Bytes and other things
> that can be used as cpointers
>  20   [#:opaque CType ctype?]
>  21   )
>  ..
> which seems perfectly innocuous to me :-/
>

You're right, it's innocuous. So we can use `unsafe-require/typed`:

#lang typed/racket/base
(require (only-in typed/racket/unsafe unsafe-require/typed))

(unsafe-require/typed ffi/unsafe
  [#:opaque CPointer cpointer?]
  [#:opaque CType ctype?]
)
(require/typed ffi/unsafe
  [malloc (-> Fixnum CPointer)]
)

(malloc 4) ;; no warnings


---

Here's the discussion behind the warning messages:
https://github.com/racket/typed-racket/pull/396

Basically, the trouble is that `cpointer?` might be an evil untyped
function:

(define (cpointer? x)
  (when (box? x)
    (set-box! x 'EVIL))
  #t)


Typed Racket can't be sure, so it tries to protect all arguments to
`cpointer?`.
But when you call `(cpointer? v)` where `v` is a `#<cpointer>`, Typed
Racket warns you that it doesn't know how to protect `#<cpointer>` values.

-- 
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 racket-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.