I have something of a subtle (I think) problem in Lisp, related to an earlier question I asked: How do I name a variable after a string in Lisp?
Here's how it goes:
- I'm creating a language in which (among other things) the user inputs text strings, and my parser then creates uniquely-identified entity (and other stuff) based on their input.
- A typical and simple input would be: my_name:my_contents -- where my_name is the name of the entity, and my_contents is a string.
- So, I need to find a way to set up a lisp program that takes the user input, then creates the entities and identifies them based on the user's input.
So far I've considered two approaches:
A. One variable per entity: when the user enters a string, Lisp takes my_name and creates a variable with that name, and puts my_contents inside. The drawback here is that I can't figure out how to set the name of the variable to some user-defined and mutable input such as my_name.
B. A table, such as a hash-table: when the user enters a string, Lisp adds a row to a hash table with my_name as the key and my_contents as the entry. The drawback with this approach is that again I can't find a way to set the key as my_name at any given moment.
In summary, I'm looking for counsel on 1. how to name a variable after a user-defined string or 2. how to set a user-defined string as a key in a hash table or 3. whether there's a better approach.
Thanks in advance!