# How to use datatype defined in ATS in C

**URL:** https://discourse.ats-lang.org/t/how-to-use-datatype-defined-in-ats-in-c/525
**Category:** Google Group
**Created:** [March 21, 2014, 11:21am UTC](https://discourse.ats-lang.org/t/how-to-use-datatype-defined-in-ats-in-c/525 "2014-03-21T11:21:09Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Chotu\_S](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@Chotu\_S](https://discourse.ats-lang.org/u/Chotu_S)
#### Post date: [March 21, 2014, 11:21am UTC](https://discourse.ats-lang.org/t/how-to-use-datatype-defined-in-ats-in-c/525/1 "2014-03-21T11:21:09Z")

</div>

Suppose I have :

datatype env =  
| empty\_env of ()  
| extend\_env of (string,int,env)

What is its equivalent in C . I tried to follow the example in “Interaction  
with C” , but cannot seem to make it work.

In C suppose I have two function : make\_empty\_env , and make\_extend\_env ,  
what should be there signatures?

1. return\_type??? make\_empty\_env () { … }

2. return\_type??? make\_extend\_env (char \* s , int , ???) {…}

Thanks

---

<div class="post-metadata">

### Author: ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)
#### Post date: [March 21, 2014, 3:50pm UTC](https://discourse.ats-lang.org/t/how-to-use-datatype-defined-in-ats-in-c/525/2 "2014-03-21T15:50:41Z")

</div>

extern void \*make\_empty\_env () ;  
extern void \*make\_extend\_env (char _arg0, int arg1, void_ arg2) ;On Friday, March 21, 2014 7:21:09 AM UTC-4, chotu s wrote:

> Suppose I have :
> 
> datatype env =  
> | empty\_env of ()  
> | extend\_env of (string,int,env)
> 
> What is its equivalent in C . I tried to follow the example in  
> “Interaction with C” , but cannot seem to make it work.
> 
> In C suppose I have two function : make\_empty\_env , and make\_extend\_env ,  
> what should be there signatures?
> 
> 1. return\_type??? make\_empty\_env () { … }
> 
> 2. return\_type??? make\_extend\_env (char \* s , int , ???) {…}
> 
> Thanks
