Re: reduced size symbols/keywords



På Fri, 29 Aug 2008 10:59:54 +0200, skrev Pascal J. Bourguignon <pjb@xxxxxxxxxxxxxxxxx>:


That wouldn't be a symbol anymore. As indicated by John, use a
hashtable to unify your strings. You don't necessarily need to cons
integers:

(defparameter *unique-strings* (make-hash-table :test (function equal)))

(defun intern-string (s)
(or (gethash s *unique-strings*)
(setf (gethash s *unique-strings*) s)))

(let ((us1 (intern-string (read-line)))
(us2 (intern-string (read-line))))
(when (eq us1 us2)
(princ "Two identical successive strings.")))


is cute, I'm ok with those new keywords/symbols to forego everything
(function, plist, package) but the value slot.

What do you need the value slot for?


Fair enough. I was thinking more in terms of a lexer.
If you have more control over the value returned you can use this.
consider

(get-symval "reserved1")
....
(get-symval "reservedn")

(setf *reserved-word* (get-symcounter))

(defun reserved-wordp (sym)
(< sym *reserved-word*))

So you use the fact that reserved words are inserted before the ones introduced by the user.

--------------
John Thingstad
.