Would it be possible to add "make-symbol"?


#1

Another suggestion: Is “make-symbol” feasible? If I’m not wrong this seems to be the only way to create a global variable from a name string within a function like so:

(defun myfun (mynamestring) (defvar (make-symbol mynamestring) 42))

While this little example does not make much sense, I miss “make-symbol” as a way to create fully capable factory functions for ULOS objects. My workaround (can be done, of course) is to create the global variable containing the object instance outside the factory function first and pass it to the factory function. Again, one can do this, of course, but I consider it somewhat unelegant - a real factory function should be able to create a whole object instance by itself.
Admitted, this is not essential, but maybe an implementation of “make-symbol” would be not a big deal. Or maybe it would be - I’m not capable of judging that. And maybe I’m once again missing another better way to achieve the same, of course.

Thank you once more for having created uLisp - the farther I get into it the more I appreciate how much is possible with this elegant tiny expandable and accessible core that can even be understood (to some extent) by people new to Lisp.


What would you like to see in uLisp in 2024?
#2

I’ll look into adding make-symbol, but in the meantime you can do the following:

(defun myfun (mynamestring)
  (eval 
   (read-from-string 
    (format nil "(defvar ~a 42)" mynamestring))))

For example:

2781> (myfun "bingo")
bingo

2777> bingo
42

PS Thank you for your kind comments about uLisp!


#3

Great, thanks! Also for the workaround (which has the nice side effect of introducing me to the incredibly versatile “format” function I hadn’t even noticed so far…)