Some C library functions pass value through setters. For example to get a
string one passes a pointer to a string (char**):
PL_get_atom_chars(term_t some_atom, char** ptr_to_string)
How does one model and interface with C functions like this? I suppose we
use references?
Then you may need to write a thin wrapper to suppress such warnings:
#define atscntrb_PL_get_atom_char (…) PL_get_atom_char (…)On Friday, January 24, 2014 6:24:09 PM UTC-5, H Zhang wrote:
Oh. And I still get the wrong type warning from gcc (about expecting char
** but got void **). It seems the tmp variable is declared to be of type
atstype_ptrk instead of atstype_string.
On Friday, January 24, 2014 3:14:43 PM UTC-8, H Zhang wrote:
I experimented and see that is actually works to declare a
var x: string
and then call the function with it and ATS knows to take the reference of
x to pass into the function. That is really cool although still a little
magic to me. With time I will want to learn more about how this is actually
achieved.
On Friday, January 24, 2014 3:00:44 PM UTC-8, H Zhang wrote:
I see. But how does one actually call a function like this in ATS? How
do I have a var pre-allocated (but uninitialized)? I can’t take the
reference to an automatic variable like in C, can I?
On Friday, January 24, 2014 2:22:42 PM UTC-8, gmhwxi wrote:
The meaning of &string? >> string is this:
please pass a left-value whose content is uninitialized string (which
is essentially an uninitialized pointer);
after the call returns, the content of the left-value is a string.
So it is precisely what you want according to the description you gave…
On Friday, January 24, 2014 5:16:15 PM UTC-5, H Zhang wrote:
I am trying to understand the notation of &string? >> string
Does it say that some type was pointer to a string and on return
becomes string?
That is actually not what I wanted, so maybe here it is my English
that was vague I believe what the interface function is saying is call
me with a pointer to string and I will set it to point to the return
string. In C we would do:
char *some_string;
PL_get_atom_chars(some_atom, &some_string);
do_something_with(some_string);
On Friday, January 24, 2014 12:11:24 PM UTC-8, gmhwxi wrote:
C-types are so vague
My guess is:
fun PL_get_atom_chars (term_t, &string? >> string): …
On Friday, January 24, 2014 2:56:39 PM UTC-5, H Zhang wrote:
Some C library functions pass value through setters. For example to
get a string one passes a pointer to a string (char**):
PL_get_atom_chars(term_t some_atom, char** ptr_to_string)
How does one model and interface with C functions like this? I
suppose we use references?
Some C library functions pass value through setters. For example to get a
string one passes a pointer to a string (char**):
PL_get_atom_chars(term_t some_atom, char** ptr_to_string)
How does one model and interface with C functions like this? I suppose we
use references?
In your example, shouldn’t char** also be a pointer to an array of strings?
char* is a string.On Friday, January 24, 2014 2:56:39 PM UTC-5, H Zhang wrote:
Some C library functions pass value through setters. For example to get a
string one passes a pointer to a string (char**):
PL_get_atom_chars(term_t some_atom, char** ptr_to_string)
How does one model and interface with C functions like this? I suppose we
use references?
Oh. And I still get the wrong type warning from gcc (about expecting char
** but got void **). It seems the tmp variable is declared to be of type
atstype_ptrk instead of atstype_string.On Friday, January 24, 2014 3:14:43 PM UTC-8, H Zhang wrote:
I experimented and see that is actually works to declare a
var x: string
and then call the function with it and ATS knows to take the reference of
x to pass into the function. That is really cool although still a little
magic to me. With time I will want to learn more about how this is actually
achieved.
On Friday, January 24, 2014 3:00:44 PM UTC-8, H Zhang wrote:
I see. But how does one actually call a function like this in ATS? How do
I have a var pre-allocated (but uninitialized)? I can’t take the reference
to an automatic variable like in C, can I?
On Friday, January 24, 2014 2:22:42 PM UTC-8, gmhwxi wrote:
The meaning of &string? >> string is this:
please pass a left-value whose content is uninitialized string (which is
essentially an uninitialized pointer);
after the call returns, the content of the left-value is a string.
So it is precisely what you want according to the description you gave…
On Friday, January 24, 2014 5:16:15 PM UTC-5, H Zhang wrote:
I am trying to understand the notation of &string? >> string
Does it say that some type was pointer to a string and on return
becomes string?
That is actually not what I wanted, so maybe here it is my English that
was vague I believe what the interface function is saying is call me
with a pointer to string and I will set it to point to the return string.
In C we would do:
char *some_string;
PL_get_atom_chars(some_atom, &some_string);
do_something_with(some_string);
On Friday, January 24, 2014 12:11:24 PM UTC-8, gmhwxi wrote:
C-types are so vague
My guess is:
fun PL_get_atom_chars (term_t, &string? >> string): …
On Friday, January 24, 2014 2:56:39 PM UTC-5, H Zhang wrote:
Some C library functions pass value through setters. For example to
get a string one passes a pointer to a string (char**):
PL_get_atom_chars(term_t some_atom, char** ptr_to_string)
How does one model and interface with C functions like this? I
suppose we use references?
It may be the case that the type of an unitialized and unallocated variable
is the same: if it is unitialized, there is not really a valid view of it,
I think
Brandon Barker
brandon…@gmail.comOn Fri, Jan 24, 2014 at 6:14 PM, H Zhang zht...@gmail.com wrote:
I experimented and see that is actually works to declare a
var x: string
and then call the function with it and ATS knows to take the reference of
x to pass into the function. That is really cool although still a little
magic to me. With time I will want to learn more about how this is actually
achieved.
On Friday, January 24, 2014 3:00:44 PM UTC-8, H Zhang wrote:
I see. But how does one actually call a function like this in ATS? How do
I have a var pre-allocated (but uninitialized)? I can’t take the reference
to an automatic variable like in C, can I?
On Friday, January 24, 2014 2:22:42 PM UTC-8, gmhwxi wrote:
The meaning of &string? >> string is this:
please pass a left-value whose content is uninitialized string (which is
essentially an uninitialized pointer);
after the call returns, the content of the left-value is a string.
So it is precisely what you want according to the description you gave…
On Friday, January 24, 2014 5:16:15 PM UTC-5, H Zhang wrote:
I am trying to understand the notation of &string? >> string
Does it say that some type was pointer to a string and on return
becomes string?
That is actually not what I wanted, so maybe here it is my English that
was vague I believe what the interface function is saying is call me
with a pointer to string and I will set it to point to the return string.
In C we would do:
char *some_string;
PL_get_atom_chars(some_atom, &some_string);
do_something_with(some_string);
On Friday, January 24, 2014 12:11:24 PM UTC-8, gmhwxi wrote:
C-types are so vague
My guess is:
fun PL_get_atom_chars (term_t, &string? >> string): …
On Friday, January 24, 2014 2:56:39 PM UTC-5, H Zhang wrote:
Some C library functions pass value through setters. For example to
get a string one passes a pointer to a string (char**):
PL_get_atom_chars(term_t some_atom, char** ptr_to_string)
How does one model and interface with C functions like this? I
suppose we use references?
fun PL_get_atom_chars (term_t, &string? >> string): …On Friday, January 24, 2014 2:56:39 PM UTC-5, H Zhang wrote:
Some C library functions pass value through setters. For example to get a
string one passes a pointer to a string (char**):
PL_get_atom_chars(term_t some_atom, char** ptr_to_string)
How does one model and interface with C functions like this? I suppose we
use references?
I see. But how does one actually call a function like this in ATS? How do I
have a var pre-allocated (but uninitialized)? I can’t take the reference to
an automatic variable like in C, can I?On Friday, January 24, 2014 2:22:42 PM UTC-8, gmhwxi wrote:
The meaning of &string? >> string is this:
please pass a left-value whose content is uninitialized string (which is
essentially an uninitialized pointer);
after the call returns, the content of the left-value is a string.
So it is precisely what you want according to the description you gave…
On Friday, January 24, 2014 5:16:15 PM UTC-5, H Zhang wrote:
I am trying to understand the notation of &string? >> string
Does it say that some type was pointer to a string and on return becomes
string?
That is actually not what I wanted, so maybe here it is my English that
was vague I believe what the interface function is saying is call me
with a pointer to string and I will set it to point to the return string.
In C we would do:
char *some_string;
PL_get_atom_chars(some_atom, &some_string);
do_something_with(some_string);
On Friday, January 24, 2014 12:11:24 PM UTC-8, gmhwxi wrote:
C-types are so vague
My guess is:
fun PL_get_atom_chars (term_t, &string? >> string): …
On Friday, January 24, 2014 2:56:39 PM UTC-5, H Zhang wrote:
Some C library functions pass value through setters. For example to get
a string one passes a pointer to a string (char**):
PL_get_atom_chars(term_t some_atom, char** ptr_to_string)
How does one model and interface with C functions like this? I suppose
we use references?
I am trying to understand the notation of &string? >> string
Does it say that some type was pointer to a string and on return becomes
string?
That is actually not what I wanted, so maybe here it is my English that was
vague I believe what the interface function is saying is call me with a
pointer to string and I will set it to point to the return string. In C we
would do:
char *some_string;
PL_get_atom_chars(some_atom, &some_string);
do_something_with(some_string);On Friday, January 24, 2014 12:11:24 PM UTC-8, gmhwxi wrote:
C-types are so vague
My guess is:
fun PL_get_atom_chars (term_t, &string? >> string): …
On Friday, January 24, 2014 2:56:39 PM UTC-5, H Zhang wrote:
Some C library functions pass value through setters. For example to get a
string one passes a pointer to a string (char**):
PL_get_atom_chars(term_t some_atom, char** ptr_to_string)
How does one model and interface with C functions like this? I suppose we
use references?
please pass a left-value whose content is uninitialized string (which is
essentially an uninitialized pointer);
after the call returns, the content of the left-value is a string.
So it is precisely what you want according to the description you gave…On Friday, January 24, 2014 5:16:15 PM UTC-5, H Zhang wrote:
I am trying to understand the notation of &string? >> string
Does it say that some type was pointer to a string and on return becomes
string?
That is actually not what I wanted, so maybe here it is my English that
was vague I believe what the interface function is saying is call me
with a pointer to string and I will set it to point to the return string.
In C we would do:
char *some_string;
PL_get_atom_chars(some_atom, &some_string);
do_something_with(some_string);
On Friday, January 24, 2014 12:11:24 PM UTC-8, gmhwxi wrote:
C-types are so vague
My guess is:
fun PL_get_atom_chars (term_t, &string? >> string): …
On Friday, January 24, 2014 2:56:39 PM UTC-5, H Zhang wrote:
Some C library functions pass value through setters. For example to get
a string one passes a pointer to a string (char**):
PL_get_atom_chars(term_t some_atom, char** ptr_to_string)
How does one model and interface with C functions like this? I suppose
we use references?
I experimented and see that is actually works to declare a
var x: string
and then call the function with it and ATS knows to take the reference of x
to pass into the function. That is really cool although still a little
magic to me. With time I will want to learn more about how this is actually
achieved.On Friday, January 24, 2014 3:00:44 PM UTC-8, H Zhang wrote:
I see. But how does one actually call a function like this in ATS? How do
I have a var pre-allocated (but uninitialized)? I can’t take the reference
to an automatic variable like in C, can I?
On Friday, January 24, 2014 2:22:42 PM UTC-8, gmhwxi wrote:
The meaning of &string? >> string is this:
please pass a left-value whose content is uninitialized string (which is
essentially an uninitialized pointer);
after the call returns, the content of the left-value is a string.
So it is precisely what you want according to the description you gave…
On Friday, January 24, 2014 5:16:15 PM UTC-5, H Zhang wrote:
I am trying to understand the notation of &string? >> string
Does it say that some type was pointer to a string and on return becomes
string?
That is actually not what I wanted, so maybe here it is my English that
was vague I believe what the interface function is saying is call me
with a pointer to string and I will set it to point to the return string.
In C we would do:
char *some_string;
PL_get_atom_chars(some_atom, &some_string);
do_something_with(some_string);
On Friday, January 24, 2014 12:11:24 PM UTC-8, gmhwxi wrote:
C-types are so vague
My guess is:
fun PL_get_atom_chars (term_t, &string? >> string): …
On Friday, January 24, 2014 2:56:39 PM UTC-5, H Zhang wrote:
Some C library functions pass value through setters. For example to
get a string one passes a pointer to a string (char**):
PL_get_atom_chars(term_t some_atom, char** ptr_to_string)
How does one model and interface with C functions like this? I suppose
we use references?