[plt-scheme] _bytes doesn't work as a simple ctype

From: Eli Barzilay (eli at barzilay.org)
Date: Sun Jun 12 14:58:22 EDT 2005

On Jun 13, Chihiro Kuraya wrote:
> 
> "PLT Foreign Interface Manual" says that _bytes can be used as a
> simple ctype as well as a custom-type macro.

It can.


> But the following code generates an error.
> 
> -----------------------------------------------------------------------
> (let ((ptr (malloc _byte 128))
>       (data (make-bytes 16 0)))
>   (ptr-set! _bytes 0 data))
> -----------------------------------------------------------------------

You're missing the `ptr' as a first argument to `ptr-set!'.


> The error message displayed in DrScheme is:
> 
> -----------------------------------------------------------------------
> procedure application: expected procedure, given: #f; 
> arguments were: #<struct:fun-syntax> #<syntax:22:12>
> -----------------------------------------------------------------------

Seems like a DrScheme bug.  In the meanwhile, you can use it in a
`module' definition and it should work fine.


> This may be _bytes are considered as a custom-type macro.

No.


> [...] I think it is more convenient to separate a simple ctype from
> custom-type macro as separate symbols.

This is an unrelated issue.  I've spent some time thinking of the
names and couldn't come up with any reasonable set.  If you have any
suggestions, tell me.  (But they'd have to be good to switch at this
stage.)

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!



Posted on the users mailing list.