Re: initializing Pointer

[email protected] (Elizabeth Mattijsen)
Newsgroups perl.perl6.users
Message-ID <[email protected]>
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 <[email protected]> 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
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.