Some functions (like C’s exit(3) or longjmp(3)) never return. Is there a
way to mark them as such in ATS so that a non-void function can call
them without having to construct a fake value to return after the call?
e.g. is there some way I can write:
fn foo(bool b): int = if b then 1 else perror “bad value”; exit(1)
without sequencing the exit with some constructed value that I know will
never actually be returned?
Notice that the size of the type T = {a:t@ype}(a) is unknown, so
the compiler cannot generate proper C code for ‘loop’ (it is no problem
to generate JavaScript code, though). So you need a special way to implement
such a function for use in C.On Friday, September 12, 2014 1:40:08 PM UTC-4, Shea Levy wrote:
Ah ha! I see that’s implemented by making exit a template and
implementing it as a macro. My attempt to implement something similar
with an infinte loop failed:
fun loop (): {a: t@ype}(a) = loop ()
implement main () = loop ()
Gives:
test_dats.c:119:1: error: ‘loop_0’ declared as function returning an
array
during c compilation. Do I have to resort to a macro/function in C here?
~Shea
On Fri, Sep 12, 2014 at 10:22:57AM -0700, gmhwxi wrote:
It works if you write:
fn foo{b:bool}(b: bool b): int =
if b then 1 else (perror “bad value”; exit(1))
For any type T, exit(1){T} is considered by the typechecker a value of
the
type T. So you can write:
fn foo{b:bool}(b: bool b): int =
if b then 1 else (perror “bad value”; exit(1){int})
On Friday, September 12, 2014 1:12:51 PM UTC-4, Shea Levy wrote:
Hi all,
Some functions (like C’s exit(3) or longjmp(3)) never return. Is there
a
way to mark them as such in ATS so that a non-void function can call
them without having to construct a fake value to return after the
call?
e.g. is there some way I can write:
fn foo(bool b): int = if b then 1 else perror “bad value”; exit(1)
without sequencing the exit with some constructed value that I know
will
never actually be returned?
Perfect!On Fri, Sep 12, 2014 at 12:11:16PM -0700, gmhwxi wrote:
How about
ptr0_get(the_null_ptr)
On Friday, September 12, 2014 3:07:15 PM UTC-4, Shea Levy wrote:
Ah, right. I wonder if something like:
#define FAKE_VAL(ty) *((ty *) NULL)
could be done in ATS?
~Shea
On Fri, Sep 12, 2014 at 10:53:04AM -0700, gmhwxi wrote:
Notice that the size of the type T = {a:t@ype}(a) is unknown, so
the compiler cannot generate proper C code for ‘loop’ (it is no problem
to generate JavaScript code, though). So you need a special way to
implement
such a function for use in C.
On Friday, September 12, 2014 1:40:08 PM UTC-4, Shea Levy wrote:
Ah ha! I see that’s implemented by making exit a template and
implementing it as a macro. My attempt to implement something similar
with an infinte loop failed:
fun loop (): {a: t@ype}(a) = loop ()
implement main () = loop ()
Gives:
test_dats.c:119:1: error: ‘loop_0’ declared as function returning an
array
during c compilation. Do I have to resort to a macro/function in C
here?
~Shea
On Fri, Sep 12, 2014 at 10:22:57AM -0700, gmhwxi wrote:
It works if you write:
fn foo{b:bool}(b: bool b): int =
if b then 1 else (perror “bad value”; exit(1))
For any type T, exit(1){T} is considered by the typechecker a value
of
the
type T. So you can write:
fn foo{b:bool}(b: bool b): int =
if b then 1 else (perror “bad value”; exit(1){int})
On Friday, September 12, 2014 1:12:51 PM UTC-4, Shea Levy wrote:
Hi all,
Some functions (like C’s exit(3) or longjmp(3)) never return. Is
there
a
way to mark them as such in ATS so that a non-void function can
call
them without having to construct a fake value to return after the
call?
e.g. is there some way I can write:
fn foo(bool b): int = if b then 1 else perror “bad value”;
exit(1)
without sequencing the exit with some constructed value that I
know
will
never actually be returned?
~Shea
–
You received this message because you are subscribed to the Google
Groups “ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it,
send
an email to ats-lang...@googlegroups.com <javascript:>.
To post to this group, send email to ats-l...@googlegroups.com
<javascript:>.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
~SheaOn Fri, Sep 12, 2014 at 10:53:04AM -0700, gmhwxi wrote:
Notice that the size of the type T = {a:t@ype}(a) is unknown, so
the compiler cannot generate proper C code for ‘loop’ (it is no problem
to generate JavaScript code, though). So you need a special way to implement
such a function for use in C.
On Friday, September 12, 2014 1:40:08 PM UTC-4, Shea Levy wrote:
Ah ha! I see that’s implemented by making exit a template and
implementing it as a macro. My attempt to implement something similar
with an infinte loop failed:
fun loop (): {a: t@ype}(a) = loop ()
implement main () = loop ()
Gives:
test_dats.c:119:1: error: ‘loop_0’ declared as function returning an
array
during c compilation. Do I have to resort to a macro/function in C here?
~Shea
On Fri, Sep 12, 2014 at 10:22:57AM -0700, gmhwxi wrote:
It works if you write:
fn foo{b:bool}(b: bool b): int =
if b then 1 else (perror “bad value”; exit(1))
For any type T, exit(1){T} is considered by the typechecker a value of
the
type T. So you can write:
fn foo{b:bool}(b: bool b): int =
if b then 1 else (perror “bad value”; exit(1){int})
On Friday, September 12, 2014 1:12:51 PM UTC-4, Shea Levy wrote:
Hi all,
Some functions (like C’s exit(3) or longjmp(3)) never return. Is there
a
way to mark them as such in ATS so that a non-void function can call
them without having to construct a fake value to return after the
call?
e.g. is there some way I can write:
fn foo(bool b): int = if b then 1 else perror “bad value”; exit(1)
without sequencing the exit with some constructed value that I know
will
never actually be returned?
Ah ha! I see that’s implemented by making exit a template and
implementing it as a macro. My attempt to implement something similar
with an infinte loop failed:
fun loop (): {a: t@ype}(a) = loop ()
implement main () = loop ()
Gives:
test_dats.c:119:1: error: ‘loop_0’ declared as function returning an array
during c compilation. Do I have to resort to a macro/function in C here?
~SheaOn Fri, Sep 12, 2014 at 10:22:57AM -0700, gmhwxi wrote:
It works if you write:
fn foo{b:bool}(b: bool b): int =
if b then 1 else (perror “bad value”; exit(1))
For any type T, exit(1){T} is considered by the typechecker a value of the
type T. So you can write:
fn foo{b:bool}(b: bool b): int =
if b then 1 else (perror “bad value”; exit(1){int})
On Friday, September 12, 2014 1:12:51 PM UTC-4, Shea Levy wrote:
Hi all,
Some functions (like C’s exit(3) or longjmp(3)) never return. Is there a
way to mark them as such in ATS so that a non-void function can call
them without having to construct a fake value to return after the call?
e.g. is there some way I can write:
fn foo(bool b): int = if b then 1 else perror “bad value”; exit(1)
without sequencing the exit with some constructed value that I know will
never actually be returned?
fn foo{b:bool}(b: bool b): int =
if b then 1 else (perror “bad value”; exit(1))
For any type T, exit(1){T} is considered by the typechecker a value of the
type T. So you can write:
fn foo{b:bool}(b: bool b): int =
if b then 1 else (perror “bad value”; exit(1){int})On Friday, September 12, 2014 1:12:51 PM UTC-4, Shea Levy wrote:
Hi all,
Some functions (like C’s exit(3) or longjmp(3)) never return. Is there a
way to mark them as such in ATS so that a non-void function can call
them without having to construct a fake value to return after the call?
e.g. is there some way I can write:
fn foo(bool b): int = if b then 1 else perror “bad value”; exit(1)
without sequencing the exit with some constructed value that I know will
never actually be returned?
ptr0_get(the_null_ptr)On Friday, September 12, 2014 3:07:15 PM UTC-4, Shea Levy wrote:
Ah, right. I wonder if something like:
#define FAKE_VAL(ty) *((ty *) NULL)
could be done in ATS?
~Shea
On Fri, Sep 12, 2014 at 10:53:04AM -0700, gmhwxi wrote:
Notice that the size of the type T = {a:t@ype}(a) is unknown, so
the compiler cannot generate proper C code for ‘loop’ (it is no problem
to generate JavaScript code, though). So you need a special way to
implement
such a function for use in C.
On Friday, September 12, 2014 1:40:08 PM UTC-4, Shea Levy wrote:
Ah ha! I see that’s implemented by making exit a template and
implementing it as a macro. My attempt to implement something similar
with an infinte loop failed:
fun loop (): {a: t@ype}(a) = loop ()
implement main () = loop ()
Gives:
test_dats.c:119:1: error: ‘loop_0’ declared as function returning an
array
during c compilation. Do I have to resort to a macro/function in C
here?
~Shea
On Fri, Sep 12, 2014 at 10:22:57AM -0700, gmhwxi wrote:
It works if you write:
fn foo{b:bool}(b: bool b): int =
if b then 1 else (perror “bad value”; exit(1))
For any type T, exit(1){T} is considered by the typechecker a value
of
the
type T. So you can write:
fn foo{b:bool}(b: bool b): int =
if b then 1 else (perror “bad value”; exit(1){int})
On Friday, September 12, 2014 1:12:51 PM UTC-4, Shea Levy wrote:
Hi all,
Some functions (like C’s exit(3) or longjmp(3)) never return. Is
there
a
way to mark them as such in ATS so that a non-void function can
call
them without having to construct a fake value to return after the
call?
e.g. is there some way I can write:
fn foo(bool b): int = if b then 1 else perror “bad value”;
exit(1)
without sequencing the exit with some constructed value that I
know
will
never actually be returned?
~Shea
–
You received this message because you are subscribed to the Google
Groups “ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it,
send
an email to ats-lang...@googlegroups.com <javascript:>.
To post to this group, send email to ats-l...@googlegroups.com
<javascript:>.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit