NCI 't' parameter type removed; no replacement?

Peter Lobsinger plobsing at gmail.com
Sun May 15 23:10:59 UTC 2011


On Sun, May 15, 2011 at 5:41 PM, Kevin Tew <tewk at tewk.com> wrote:
> Byte strings, the former 't' NCI type, are as primitive a data type as int
> is for libraries written in C.
> I think some of Jonathan and Patrick extreme surprise is that we are making
> the extremely common use of C byte strings more laborious to use than they
> were in the past.
>
> The whole point of a ffi interface is to remove the repetitive nature of the
> mundane cases and make the arcane cases possible.

I would put more emphasis on make possible than on make easy, at least
at the opcode-level. A simple native call interface operating on
primitives and doing minimal marshalling facilitates alternate
implementations. Of particular interest would be an alternate
implementation that tied in with just-in-time native code generation
functionality.

We already provide a runtime library, NCI::Utils, whose aim is to make
the common cases of NCI easy. I suggest we provide the sugar layer
there.

> We shouldn't force NCI/ffi/(whatever we are calling it these days) users to
> become responsible for manually marshaling such a primitive datatype such as
> C bytes stings to and form parrot Strings.
> I understand for some extravagant use cases manual marshaling will be
> necessary.
>
> However, we should make the extremely common case of 't' easy. ( Provide a
> NCI type that automatically marshals)
> And make the uncommon cases possible. (Via manual marshaling.)

I can understand the argument that char pointer as string convention
has become much more cumbersome. However, I don't think that embedding
such a convenience functionality directly into the NCI is the best
solution to this problem. Look at the other NCI types. These are all C
or Parrot primitives and their translation is fairly simple. By
comparison, the translation of Parrot strings to asciiz strings is a
much more complex operation. It is a composite operation that can be
built out of the primitives.

Due to the fact that this form of marshalling is so common, I propose
the functionality be made available in the NCI::Utils helper library
that exists solely to make common NCI situations easier.

> Kevin
>
>
> On 05/15/2011 02:16 PM, Donald Hunter wrote:
>
> Hi,
> I raised my concern about the removal of NCI signatures breaking Zavolaj on
> 27 April. I received what I felt was a very curt response from Peter
> suggesting that:
> " PCRE's pcre_compile function also makes use of pass-by-reference. This
> binding has been updated to the new API and makes a good reference, in
> my opinion."
> It was hard to find the example and it wasn't directly relevant.
> Unfortunately the response I got was enough to dissuade me from contributing
> the scarce time I had available to work on Zavolaj.
> I think it would have been more helpful to have backed off removing features
> that I'd just said were in use, rather than pressing ahead and leaving me to
> figure it out.
> Cheers,
> Donald.
>
>
> _______________________________________________
> http://lists.parrot.org/mailman/listinfo/parrot-dev
>
>
> _______________________________________________
> http://lists.parrot.org/mailman/listinfo/parrot-dev
>
>


More information about the parrot-dev mailing list