[m-users.] Question about map internal representation for repeated values on different keys

Sean Charles (emacstheviking) objitsu at gmail.com
Tue Nov 30 09:36:43 AEDT 2021


What does map(string, string) do if I insert many keys that have the same value, does it re-share that string value?
My particular use case is for something in my language called a type map, which looks a little like this:

(#f:typemap ;; has to work as (alist... as well!
        :VARIABLES {
            ('argc' . "psz")
            (argv   . char**)
            (argv   . :ppc)
        }
        :Types {
            "int”         i
            “int”         [ j k n ]
            "char"        [ c ch chr ]
            "const char*" psz
            "char**"      ppc
        }
)

The :variables section defines types for variables explicitly, no type decoration is needed in the source code. The :types section allows aliases to be specified. The keys are mixed case as an ongoing test, but my question is, when I process it the following map entries will be made

	i	int
	j	int
	k	int
	n	int
	c	char
	ch	char
	chr	chr
	psz	const char*
	ppc	char**

I am doing this just because it feels easier later i.e. when I split a variable into its name and type I act thus:

	var	        find type in :variables section, further resolved from :types
	var ’/‘ type	find type in :types section

Perhaps there is even some other storage mechanism that the libraries offer? To be honest, I am on a roll with it this evening and I want to just complete this part of the transpiler system as I have spent far too long on it already!
Suggestions welcome as always.

Thank you all,
Sean.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20211129/9fb24d66/attachment.html>


More information about the users mailing list