I am trying to do it in another way, but I got into another trouble.
What I am trying to do is to prepare a command in some function like
fun redis_command_prepare {ts: types} (fmt: printf_c (ts), args: ts):
string = let
val cmd = sprintf (fmt, args)
in
string_of_strptr (cmd)
end
But it gives me type mismatch error
mismatch of static terms (tyleq):
The needed term is: S2Evararg(S2Evar(ts(2611)))
The actual term is: S2Eapp(S2Ecst(va_list_types_viewt0ype);
S2Evar(ts(2611)))
exit(ATS): uncaught exception:
ATS_2d0_2e2_2e10_2src_2ats_error_2esats__FatalErrorException(1027)
I’ve discussed this with Alex, but we can’t figure it out. What do you
think?
Maybe it is better to implement redis_command_prepare in C and then give it
a type in ATS.
While it is possible to do it in ATS, it is quite involved and whatever
gain you may get is quite limited.
I have not made any progress on this issue. Also, stdarg.sats
is yet to be supported in ATS2.
Handling variadic functions like printf is planned to be addressed as an
issue of meta-programming.
For now, please call scanf and fprintf externally by using $extfcall. Scanf
will be difficult to handled
anyway.On Monday, May 12, 2014 8:13:32 PM UTC-4, Brandon Barker wrote:
Any updates on this topic? Primarily just curious about what the best way
to call multityped c-variadic functions is, as I’m about to do a lot of it
(e.g. scanf and fprintf - and am hoping the answer is not to create a
separate function for each).
I don’t see stdarg.sats anymore - any suggested examples?
On Tuesday, July 30, 2013 4:02:20 PM UTC-4, Steinway Wu wrote:
As I mentioned in our private talk, it’s really not easy to type check
the format string with all parameters, since they are not one-one mapping.
I will try something else.
As to the first limitation, could this be handled by using a full-fledged
tokenizer rather than a functional list only?
Brandon Barker
brandon…@gmail.comOn Mon, May 12, 2014 at 10:26 PM, gmhwxi gmh...@gmail.com wrote:
Thanks for the link.
The approach is largely based on the one by Olivier Danvy.
Its limitation is well-known (e.g., it does not support non-static format
strings).
Supporting something like printf (“%2.2d”, …) would be harder.
Also, supporting scanf would be much harder due to the need for
error-handling.
Actually, printf also needs error-handling; supporting it in Idris, I
think, can be a real
challenge.
On Monday, May 12, 2014 8:18:14 PM UTC-4, Chris Double wrote:
On Tue, May 13, 2014 at 12:13 PM, Brandon Barker brand...@gmail.com wrote:
Any updates on this topic? Primarily just curious about what the best
way to
call multityped c-variadic functions is, as I’m about to do a lot of it
(e.g. scanf and fprintf - and am hoping the answer is not to create a
separate function for each).
github githwxi
I create a separate function but it’s a bit of a pain. It’d be
wonderful if it was as easy as this Idris example:
As I mentioned in our private talk, it’s really not easy to type check the
format string with all parameters, since they are not one-one mapping. I
will try something else.
Any updates on this topic? Primarily just curious about what the best way
to call multityped c-variadic functions is, as I’m about to do a lot of it
(e.g. scanf and fprintf - and am hoping the answer is not to create a
separate function for each).
I don’t see stdarg.sats anymore - any suggested examples?On Tuesday, July 30, 2013 4:02:20 PM UTC-4, Steinway Wu wrote:
As I mentioned in our private talk, it’s really not easy to type check the
format string with all parameters, since they are not one-one mapping. I
will try something else.
Say you have parsed a format string like “%2.2f”. What do you do next?On Tuesday, May 13, 2014 9:15:21 AM UTC-4, Brandon Barker wrote:
To construct the fields of the format datatype, a parser could ignore
everything between the ‘%’ and the last encountered alphabetic character
in the word. This seems too obvious, so I’m probably missing something.
On 12 May 2014 22:47, “gmhwxi” <gmh...@gmail.com <javascript:>> wrote:
What do you mean by a full-fledged tokenizer?
On Monday, May 12, 2014 10:42:48 PM UTC-4, Brandon Barker wrote:
As to the first limitation, could this be handled by using a
full-fledged tokenizer rather than a functional list only?
On Mon, May 12, 2014 at 10:26 PM, gmhwxi gmh...@gmail.com wrote:
Thanks for the link.
The approach is largely based on the one by Olivier Danvy.
Its limitation is well-known (e.g., it does not support non-static
format strings).
Supporting something like printf (“%2.2d”, …) would be harder.
Also, supporting scanf would be much harder due to the need for
error-handling.
Actually, printf also needs error-handling; supporting it in Idris, I
think, can be a real
challenge.
On Monday, May 12, 2014 8:18:14 PM UTC-4, Chris Double wrote:
On Tue, May 13, 2014 at 12:13 PM, Brandon Barker brand...@gmail.com wrote:
Any updates on this topic? Primarily just curious about what the
best way to
call multityped c-variadic functions is, as I’m about to do a lot of
it
(e.g. scanf and fprintf - and am hoping the answer is not to create
a
separate function for each).
github githwxi
I create a separate function but it’s a bit of a pain. It’d be
wonderful if it was as easy as this Idris example:
To construct the fields of the format datatype, a parser could ignore
everything between the ‘%’ and the last encountered alphabetic character
in the word. This seems too obvious, so I’m probably missing something.On 12 May 2014 22:47, “gmhwxi” gmh...@gmail.com wrote:
What do you mean by a full-fledged tokenizer?
On Monday, May 12, 2014 10:42:48 PM UTC-4, Brandon Barker wrote:
As to the first limitation, could this be handled by using a full-fledged
tokenizer rather than a functional list only?
On Mon, May 12, 2014 at 10:26 PM, gmhwxi gmh...@gmail.com wrote:
Thanks for the link.
The approach is largely based on the one by Olivier Danvy.
Its limitation is well-known (e.g., it does not support non-static
format strings).
Supporting something like printf (“%2.2d”, …) would be harder.
Also, supporting scanf would be much harder due to the need for
error-handling.
Actually, printf also needs error-handling; supporting it in Idris, I
think, can be a real
challenge.
On Monday, May 12, 2014 8:18:14 PM UTC-4, Chris Double wrote:
On Tue, May 13, 2014 at 12:13 PM, Brandon Barker brand...@gmail.com wrote:
Any updates on this topic? Primarily just curious about what the best
way to
call multityped c-variadic functions is, as I’m about to do a lot of
it
(e.g. scanf and fprintf - and am hoping the answer is not to create a
separate function for each).
github githwxi
I create a separate function but it’s a bit of a pain. It’d be
wonderful if it was as easy as this Idris example:
On Mon, May 12, 2014 at 10:26 PM, gmhwxi <gmh...@gmail.com <javascript:>>wrote:
Thanks for the link.
The approach is largely based on the one by Olivier Danvy.
Its limitation is well-known (e.g., it does not support non-static format
strings).
Supporting something like printf (“%2.2d”, …) would be harder.
Also, supporting scanf would be much harder due to the need for
error-handling.
Actually, printf also needs error-handling; supporting it in Idris, I
think, can be a real
challenge.
On Monday, May 12, 2014 8:18:14 PM UTC-4, Chris Double wrote:
On Tue, May 13, 2014 at 12:13 PM, Brandon Barker brand...@gmail.com wrote:
Any updates on this topic? Primarily just curious about what the best
way to
call multityped c-variadic functions is, as I’m about to do a lot of
it
(e.g. scanf and fprintf - and am hoping the answer is not to create a
separate function for each).
github githwxi
I create a separate function but it’s a bit of a pain. It’d be
wonderful if it was as easy as this Idris example: