# PlCompound (C++) with zero arguments

**URL:** <https://swi-prolog.discourse.group/t/plcompound-c-with-zero-arguments/4803>\
**Category:** Data Structure\
**Created:** [December 23, 2021, 4:33pm UTC](https://swi-prolog.discourse.group/t/plcompound-c-with-zero-arguments/4803 "2021-12-23T16:33:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)\
**Post date:** [December 23, 2021, 4:33pm UTC](https://swi-prolog.discourse.group/t/plcompound-c-with-zero-arguments/4803/1 "2021-12-23T16:33:16Z")

</div>

Dear list,

I am playing around with the c++ library. Swipl allows for compound terms with zero arguments, see,  
e.g. compound\_name\_arity with arity 0, so I was wondering if I can create compounds without arguments from C++. But the code below produces an atom:

```prolog
#include "SWI-cpp.h"
#include <iostream>

int main(int argc, char** argv)
{
    PlEngine e(argc, argv) ;

    PlTerm pred = PlCompound("noargs", PlTermv(0)) ;
    PlQuery q("atom", pred) ;
    if(q.next_solution())
        std::cout << "atom" << std::endl ;
    return 0 ;
}

```

Is this a bug or a feature? The thing is: I can easily create an atom with PlTerm(“noargs”), so it would actually make sense to create a compound with the above code.

Best wishes,

Matthias

---

<div class="post-metadata">

**Author:** ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)\
**Post date:** [December 23, 2021, 9:13pm UTC](https://swi-prolog.discourse.group/t/plcompound-c-with-zero-arguments/4803/2 "2021-12-23T21:13:14Z")

</div>

Ah, I see. It would be necessary to check current\_predicate with compound\_name\_arguments to see if zero-argument compounds are supported by the dialect.

My workaround is something like `PL_new_functor(PL_new_atom("noargs"), 0)` that also works in C++.
