[re: opengl] Is this known Racket syntax?

24 views
Skip to first unread message

Hendrik Boom

unread,
Apr 10, 2020, 10:02:25 AM4/10/20
to racket...@googlegroups.com
I'm building the new opengl binding for Racket, and keep running
into surprises.

Most of them are straightforward, but tedious, but I run into
something strange. It's a piece of syntax in the original
(presumably) corrent, but obsolete, binding -- specifically,
a strange type.

I thought I should ask before blundering through with it.

Here's the definition for glAreProgramsResidentNV as present in
the existing binding:


(define-gl glAreProgramsResidentNV 2 ((n : _int32) (programs : (_u32vector i)) (residences : (_vector o _bool n)) -> (result : _bool) -> (values result residences)) (->> exact-integer? u32vector? (values boolean? (vectorof boolean?))) check-gl-error)


Now normally the define-gl macro seems to take
a number,
a type of the function (containing names for the parameters
in the style of typed Racket's lambda arguments), and
another type to put in the documentation.

Now the type of the function here is
((n : _int32) (programs : (_u32vector i)) (residences : (_vector o _bool n)) -> (result : _bool) -> (values result residences))

An ordinary enough looking type except that -> occurs twice.

**: Is this a known Racket construct?

Or is it something peculiar to define-gl, which I'll just have
to figure out as I build the new opengl binding. It's presumably
related to the fact that the 'residences' parameter is for output.

-- hendrik


In case anyone is interested, here are the relevant
machine-readable bits from the nes and the old Khronos API specifications


The xml specfile entry for this is:

<command>
<proto group="Boolean"><ptype>GLboolean</ptype> <name>glAreProgramsResidentNV</name></proto>
<param><ptype>GLsizei</ptype> <name>n</name></param>
<param len="n">const <ptype>GLuint</ptype> *<name>programs</name></param>
<param group="Boolean" len="n"><ptype>GLboolean</ptype> *<name>residences</name></param>
<glx type="vendor" opcode="1293"/>
</command>


And here's the old specfile entry from the old Khronos opengl standard:

AreProgramsResidentNV(n, programs, residences)
return Boolean
param n SizeI in value
param programs UInt32 in array [n]
param residences Boolean out array [n]
category NV_vertex_program
dlflags notlistable
version 1.2
extension soft WINSOFT NV10
glxflags ignore
glxvendorpriv 1293
offset 578


Jay McCarthy

unread,
Apr 10, 2020, 10:05:54 AM4/10/20
to Racket Users
This comes from _fun, which define-gl expands to,

https://docs.racket-lang.org/foreign/foreign_procedures.html#%28form._%28%28lib._ffi%2Funsafe..rkt%29.__fun%29%29

The first -> is a type spec for the C function's return type and the
second -> is the output expression that is what the Racket wrapper
will return.

Jay

--
Jay McCarthy
Associate Professor @ CS @ UMass Lowell
http://jeapostrophe.github.io
Vincit qui se vincit.
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/20200410140217.b4e5xizymwunvyu6%40topoi.pooq.com.

Hendrik Boom

unread,
Apr 10, 2020, 10:17:19 AM4/10/20
to Racket Users
On Fri, Apr 10, 2020 at 10:05:34AM -0400, Jay McCarthy wrote:
> This comes from _fun, which define-gl expands to,
>
> https://docs.racket-lang.org/foreign/foreign_procedures.html#%28form._%28%28lib._ffi%2Funsafe..rkt%29.__fun%29%29
>
> The first -> is a type spec for the C function's return type and the
> second -> is the output expression that is what the Racket wrapper
> will return.

Thank you. I thought it would be something like that, but it helps a lot
to have a precise specification, which I found now that you indicated
where I should look:
https://docs.racket-lang.org/foreign/foreign_procedures.html

-- hendrik
> To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CAJYbDakT1AXhd7zBK%2BHQ%2B5-z6RnkoHj__xxyGAD6vDXt21mWrA%40mail.gmail.com.

Hendrik Boom

unread,
Apr 10, 2020, 10:26:50 AM4/10/20
to Racket Users
On Fri, Apr 10, 2020 at 10:17:12AM -0400, Hendrik Boom wrote:
> On Fri, Apr 10, 2020 at 10:05:34AM -0400, Jay McCarthy wrote:
> > This comes from _fun, which define-gl expands to,
> >
> > https://docs.racket-lang.org/foreign/foreign_procedures.html#%28form._%28%28lib._ffi%2Funsafe..rkt%29.__fun%29%29
> >
> > The first -> is a type spec for the C function's return type and the
> > second -> is the output expression that is what the Racket wrapper
> > will return.
>
> Thank you. I thought it would be something like that, but it helps a lot
> to have a precise specification, which I found now that you indicated
> where I should look:
> https://docs.racket-lang.org/foreign/foreign_procedures.html
>
> -- hendrik

This is getting far more complicated than I suspected a while ago when
I naively asked to have the opengl binding updated!

I'm starting to understand why it hadn't been.

I'm debugging by using diff to compare the old generated binding with my
new one. The only differences should be things that have changed and
things that have been added.

I'm not yet seeing light at the end of the tunnel, but I hope to soon.

-- hendrik
Reply all
Reply to author
Forward
0 new messages