Lisp macros operate on arguments that have already been read by lisp's reader. Because of that a macro can't change how it's arguments are read, and if you pass an argument that will signal an error when you try to read it, e.g. 9:00
in (test 9:00)
, the reader signals the error before the macro even starts to run.
The reader is also customizable. Not in a way that would let you read 9:00
as "9:00"
in a straightforward manner, but for example you could write a short reader macro that read @9:00
as either "9:00"
or as a date object.
Edit: Something like this:
(defvar *arguments-rt* (copy-readtable ()))
(defun timestring-reader (stream char &optional count)
(declare (ignore char count))
(with-output-to-string (s)
(loop repeat 4 do (write-char (read-char stream) s))))
(set-macro-character #\@ #'timestring-reader () *arguments-rt*)
(let ((*readtable* *arguments-rt*))
(let ((args "dinner @9:00"))
(with-input-from-string (stream args)
(loop for arg = (read stream () ())
while arg collect arg))))
-> (DINNER "9:00")
(symbol-name 'a)
. – Dan'9\:00
or'|9:00|
. – Sylwester