#Symbols represented by valid memory addresses

1 messages · Page 1 of 1 (latest)

sullen edge
#

I'm implementing a little language from a paper and it has this concept of symbols, which I want to implement as a pointer pointing to itself. These symbols are known at compile time, but referenced at runtime, so they could be in some static section of memory or whatever.

How would I create such a symbol?

formal crater
sullen edge
#

it greatly simplifies some code elsewhere in my interpreter

formal crater
#

okay

#

how do you want to create these symbols? do they have to be generated based on a comptime-known string or something?

#

or can they just be global variables you define in a file somewhere

sullen edge
#

global variables in a file

formal crater
#

as of 0.14 you can just do const foo = &foo; :)

#

tho you might need to give it a type? idk

sullen edge
#

I'll try that, I should've thought of that heh

#

what would the type be? 🤔

#

just *usize?

formal crater
#

const T = *const T;

#

though that might cause a dependency loop

sullen edge
#

lemme try

formal crater
#

in which case you'd have to do some shenanigans ^^'