guile-user
[Top][All Lists]
Advanced

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

Re: type friction C <-> scheme


From: Catonano
Subject: Re: type friction C <-> scheme
Date: Sun, 11 Jun 2017 19:15:00 +0200

2017-06-11 7:50 GMT+02:00 Mark H Weaver <address@hidden>:

> Catonano <address@hidden> writes:
>
> > 2017-06-10 0:33 GMT+02:00 Matt Wette <address@hidden>:
> >
> > I think Mike caught your real error: you were passing (list ‘* ‘int ‘*)
> and
> >> it wants (list ‘* int ‘*).  `int’ is a variable defined by guile.
> >>
> >
> > And isn't `*' a variable defined in guile too ?
> >
> >
> >>
> >> scheme@(guile-user)> (use-modules (system foreign))
> >> scheme@(guile-user)> int
> >> $1 = 8
> >>
> >
> > yes, and
> >
> > scheme@(freexl common)> *
> > $14 = #<procedure * (#:optional _ _ . _)>
>
> 'int' is a variable exported by (system foreign) whose sole purpose is
> to represent a foreign type.
>
> '*' is something completely different, namely a procedure to multiply
> numbers.  IMO, it would be a nasty hack for the FFI to check
> specifically for a multiplication procedure and interpret that as a
> pointer type.
>

Ok, there was a misunderstanding here

I thought that iin that context `*' was being exported from (system
foreign) too and it was bound to someting used to represent a C pointer

I hadn't understood that it is instead bound to the vanilla multiplication !


> > I took a look at the guile-gcrypt code again
> >
> > it's full of things like
> >
> > '(* * ,int ,size_t *)
> >
> > that is, only asterisks (pointers) are quoted
> >
> > Other types are not
> >
> > So this must be an established convention
> >
> > It just seems unconsistent to me
>
> I agree that it's inconsistent, but '* is shorter than any descriptive
> variable name that we might have chosen for this purpose, and pointers
> are common enough to warrant a short name.
>

sure. Now I understand better


>
> On the other hand, if we had used symbols uniformly for all foreign
> types, then it would have been impossible to bind your own type names
> (e.g. for struct types) without adding a global registry of foreign
> types, which would have various nasty problems such as the potential for
> collisions between unrelated libraries.
>

Right, right

Thanks for your remarks

Mark, would you mind to take a look at the other thread (#define SOMETHING
some_value) ?

I'm stuck in wrapping this funtion from Freexl

Thanks again !


reply via email to

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