The Croc Programming Language
Namespaces

Functions

word_t croc_namespace_new (CrocThread *t, const char *name)
 
word_t croc_namespace_newWithParent (CrocThread *t, word_t parent, const char *name)
 
word_t croc_namespace_newNoParent (CrocThread *t, const char *name)
 
void croc_namespace_clear (CrocThread *t, word_t ns)
 
word_t croc_namespace_pushFullName (CrocThread *t, word_t ns)
 

Detailed Description

Functions which operate on namespaces.

Function Documentation

word_t croc_namespace_new ( CrocThread t,
const char *  name 
)

Creates and pushes a new namespace object whose parent namespace will be set to the current function's environment (or the global namespace if there is no current function).

This is the same behavior as namespace name {} in Croc (though it doesn't actually declare the namespace; you'll have to store it somewhere, like in a global).

Parameters
nameis the name that the namespace will be given.
Returns
the stack index of the pushed value.
word_t croc_namespace_newWithParent ( CrocThread t,
word_t  parent,
const char *  name 
)

Creates and pushes a new namespace object whose parent is in slot parent.

Parameters
parentshould be either a namespace or null, in which case the new namespace will have no parent.
nameis the name that the namespace will be given.
Returns
the stack index of the pushed value.
word_t croc_namespace_newNoParent ( CrocThread t,
const char *  name 
)

Creates and pushes a new namespace object without a parent.

Parameters
nameis the name that the namespace will be given.
Returns
the stack index of the pushed value.
void croc_namespace_clear ( CrocThread t,
word_t  ns 
)

Removes all key-value pairs from the namespace in slot ns.

word_t croc_namespace_pushFullName ( CrocThread t,
word_t  ns 
)

Pushes the "full name" of the namespace in slot ns, which is the name of the namespace and all its parents, separated by dots.

Returns
the stack index of the pushed value.