Nuru icon indicating copy to clipboard operation
Nuru copied to clipboard

feat: Add pointer support

Open tacheraSasi opened this issue 6 months ago • 0 comments

This PR introduces basic pointer support to VintLang, allowing for more advanced data manipulation.

Key Features:

Address-of Operator (&): Get a pointer to the value of a variable. Dereference Operator (*): Access the value a pointer refers to. Implementation Details:

Lexer: Added AMPERSAND (&) and ASTERISK (*) as tokens. & is now correctly tokenized as a single operator. Parser: Registered & and * as prefix operators, allowing expressions like &x and p. Object System: Introduced a new object.Pointer type to represent pointers at runtime. Evaluator: Implemented logic to handle the creation of pointers (&) and dereferencing (). Includes defensive checks for nil and non-pointer values. Documentation: Added docs/pointers.md explaining the new feature, its syntax, and its current limitations (value pointers, not variable references). Example Usage:

let x = 42 let p = &x // p is a pointer to the value of x

print(p) // Prints the pointer's representation print(*p) // Prints 42 This feature lays the groundwork for more complex memory management and data structure implementations in the future.

tacheraSasi avatar Jun 25 '25 19:06 tacheraSasi