Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: initializing Pointer

0 views
Skip to first unread message

Elizabeth Mattijsen

unread,
Dec 20, 2023, 2:30:06 PM12/20/23
to perl6 users
Looking at the Pointer class code, it looks like you can either create it without arguments, or with an integer argument. The fact that you can parameterize the Pointer class, only indicates the type of data the pointer is pointing at.

> On 20 Dec 2023, at 20:12, Marcel Timmerman <mt1...@gmail.com> wrote:
>
> Hi,
>
> I would like to initialize a Pointer with some value but get an error. For example;
>
> my $a = Pointer[Str].new('text');
>
> The error thrown:
>
> Default constructor for 'NativeCall::Types::Pointer[Str]' only takes named arguments
>
> The way I can do it now is by creating a CArray and then do a nativecast which is a bit cumbersome.
> The reason I would like to use Pointers is when there is only one object to point to, not an array. Secondly, for the use of the deref() function to get the value it points to.
>
> Is there another way to solve this or is it a bug in the NativeCall::Types module. I have noticed that there are 3 new() methods defined accepting positional arguments.
>
> Regards,
> Marcel
>
>

0 new messages