I'm making a new language and will share with you a snippet with a new syntax you've never seen before. Try to guess what the syntax does:struct LinkedList~'a~v {
self&a next;
self&a prev;
v val;
}
impl LinkedList~'av {
self&a new(a* perm, v val) {
// The arena passed in must be a pointer if we want
// to keep a valid reference after the function returns
self&a node = perm->allocself();
Your new language appears to be a systems programming language with a strong emphasis on memory management and low-level data structures, somewhat inspired by Rust or C++. Here’s a breakdown of the syntax and what it likely does:
LinkedList~'a~v: Defines a generic structLinkedListwith two generic parameters,'aandv.'a: Likely a lifetime or arena specifier, indicating how long the data is valid.v: The type of the value stored in the node.
'a: Likely a lifetime or arena specifier, indicating how long the data is valid.
v: The type of the value stored in the node.
self&a next;: A pointer or reference to the next node in the list.
self&a prev;: A pointer or reference to the previous node in the list.
v val;: The value stored in the node.
LinkedList~'a~v: Defines a generic structLinkedListwith two generic parameters,'aandv.
'a: Likely a lifetime or arena specifier, indicating how long the data is valid.
v: The type of the value stored in the node.
'a: Likely a lifetime or arena specifier, indicating how long the data is valid.
v: The type of the value stored in the node.
self&a next;: A pointer or reference to the next node in the list.
self&a prev;: A pointer or reference to the previous node in the list.
rustCopy codeimpl LinkedList~'av {
self&a new(a* perm, v val) {
// The arena passed in must be a pointer if we want
// to keep a valid reference after the function returns
self&a node = perm->allocself();
impl LinkedList~'a~v: Implementation block for theLinkedListstruct with the same generic parameters.
self&a new(aperm, v val)**: Constructor function for creating a new node.aperm: A pointer to a memory arena or allocator, denoted bya*.v val: The value to be stored in the node.self&a node = perm->alloc~self();: Allocates memory for the new node from the arenapermand initializes it.node->next = null;: Initializes thenextpointer to null.node->prev = null;: Initializes theprevpointer to null.node->v = val;: Sets the node's value.return node;: Returns the newly created node.
aperm*: A pointer to a memory arena or allocator, denoted bya*.
v val: The value to be stored in the node.
self&a node = perm->alloc~self();: Allocates memory for the new node from the arenapermand initializes it.
node->next = null;: Initializes thenextpointer to null.
node->prev = null;: Initializes theprevpointer to null.
node->v = val;: Sets the node's value.
return node;: Returns the newly created node.
void remove(self&a this): Method to remove the current node from the this: The current node, denoted by a self-reference.if (this->prev) { this->prev->next = null; }: If the current node has a previous node, set the previous node'snextpointer to null.if (this->next) { this->next->prev = null; }: If the current node has a next node, set the next node'sprevpointer to null.
self&a this: The current node, denoted by a self-reference.
if (this->prev) { this->prev->next = null; }: If the current node has a previous node, set the previous node'snextpointer to null.
if (this->next) { this->next->prev = null; }: If the current node has a next node, set the next node'sprevpointer to null.
impl LinkedList~'a~v: Implementation block for theLinkedListstruct with the same generic parameters.
*self&a new(aperm, v val)**: Constructor function for creating a new node.
aperm*: A pointer to a memory arena or allocator, denoted bya*.
v val: The value to be stored in the node.
self&a node = perm->alloc~self();: Allocates memory for the new node from the arenapermand initializes it.
node->next = null;: Initializes thenextpointer to null.
node->prev = null;: Initializes theprevpointer to null.
node->v = val;: Sets the node's value.
return node;: Returns the newly created node.
aperm*: A pointer to a memory arena or allocator, denoted bya*.
v val: The value to be stored in the node.
self&a node = perm->alloc~self();: Allocates memory for the new node from the arenapermand initializes it.
node->next = null;: Initializes thenextpointer to null.
node->prev = null;: Initializes theprevpointer to null.
node->v = val;: Sets the node's value.
return node;: Returns the newly created node.
void remove(self&a this): Method to remove the current node from the list.
self&a this: The current node, denoted by a self-reference.
if (this->prev) { this->prev->next = null; }: If the current node has a previous node, set the previous node'snextpointer to null.
if (this->next) { this->next->prev = null; }: If the current node has a next node, set the next node'sprevpointer to null.
self&a this: The current node, denoted by a self-reference.
if (this->prev) { this->prev->next = null; }: If the current node has a previous node, set the previous node'snextpointer to null.
if (this->next) { this->next->prev = null; }: If the current node has a next node, set the next node'sprevpointer to null.
Summary
Your language uses a combination of generic types and lifetimes (or arenas) for memory management.
It has a syntax for referencing and dereferencing pointers similar to C or C++.
Thestructandimplblocks suggest an object-oriented or modular approach.
Memory allocation and node manipulation are handled explicitly, indicating a focus on low-level control and efficiency.
Your language uses a combination of generic types and lifetimes (or arenas) for memory management.
It has a syntax for referencing and dereferencing pointers similar to C or C++.
Thestructandimplblocks suggest an object-oriented or modular approach.
Memory allocation and node manipulation are handled explicitly, indicating a focus on low-level control and efficiency.
This snippet demonstrates the creation and manipulation of a doubly linked list with manual memory management.
Cite this conversation
“I'm making a new language and will share with you a snippet with a new syntax you've….” Conversation with ChatGPT (version unspecified), from the ShareChat — Chatbot Conversations in the Wild dataset. The Chat Archive, 2026. https://thechatarchive.com/c/01m84wdfpvd91x0w5vjb5myetw