size_t vs ssize_t?

59 views
Skip to first unread message

aditya siram

unread,
Dec 3, 2017, 10:34:45 PM12/3/17
to ats-lang-users
Is there a reason that both 'size_t' and 'ssize_t' exist? For example, functions in 'string.sats' all take or return 'size_t a' while 'strptr.sats' uses 'ssize_t a'. I see they're defined differently in 'integer_size.sats' but since they're both indexed similarly I'm unclear as to why the ATS prelude functions aren't standardized on one of them.
Thanks!

Hongwei Xi

unread,
Dec 3, 2017, 10:42:04 PM12/3/17
to ats-lan...@googlegroups.com
ssize_t is signed but size_t is unsigned.

For instance, strptr_length returns a ssize_t because
it returns -1 when the given strptr is a null pointer.


On Sun, Dec 3, 2017 at 10:34 PM, aditya siram <aditya...@gmail.com> wrote:
Is there a reason that both 'size_t' and 'ssize_t' exist? For example, functions in 'string.sats' all take or return 'size_t a' while 'strptr.sats' uses 'ssize_t a'. I see they're defined differently in 'integer_size.sats' but since they're both indexed similarly I'm unclear as to why the ATS prelude functions aren't standardized on one of them.
Thanks!

--
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-users+unsubscribe@googlegroups.com.
To post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/4f527316-b56f-4595-bcef-ec3059bed3e3%40googlegroups.com.

aditya siram

unread,
Dec 3, 2017, 10:59:50 PM12/3/17
to ats-lang-users
Ah, makes sense. Thanks!


On Sunday, December 3, 2017 at 9:42:04 PM UTC-6, gmhwxi wrote:
ssize_t is signed but size_t is unsigned.

For instance, strptr_length returns a ssize_t because
it returns -1 when the given strptr is a null pointer.

On Sun, Dec 3, 2017 at 10:34 PM, aditya siram <aditya...@gmail.com> wrote:
Is there a reason that both 'size_t' and 'ssize_t' exist? For example, functions in 'string.sats' all take or return 'size_t a' while 'strptr.sats' uses 'ssize_t a'. I see they're defined differently in 'integer_size.sats' but since they're both indexed similarly I'm unclear as to why the ATS prelude functions aren't standardized on one of them.
Thanks!

--
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-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages