Re: Array and Hash-Table References



In article <1190300644.908440.52520@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Kyle McGivney <KyleMcG@xxxxxxxxx> wrote:

On Sep 19, 6:46 pm, are <Propon...@xxxxxxx> wrote:
What are the pros and cons of a Lisp in which (AREF x 3) and (GETHASH
'c y), for example, becomes (x 3) and (y 'c), respectively? The
latter are more concise; is there a down side?

I'm sure this conversation has hit this board a few times before, so
stop me if I'm posting an old idea:

It is called 'funcallable data'. One place where Common Lisp has
it is 'Generic Functions'. Generic Functions are both
CLOS objects and Functions. See here for an example usage:
http://doc.gold.ac.uk/~mas01cr/papers/ilc2007/sequences-20070301.pdf

It is not current practice and introduction
would confuse people. There is some benefit of stable
coding styles and not introducing more
obfuscation.


what about the syntax #z(a 3) for (aref a 3)?

(defun access-array (stream char arg)
(declare (ignore char arg))
(let ((args (read stream)))
`(aref ,(first args) ,(second args))))

(set-dispatch-macro-character #\# #\z #'access-array)

You could either try and write a #y for hash tables or extend this
somehow to check the type of the data...

Kyle

--
http://lispm.dyndns.org
.



Relevant Pages

  • Re: Array and Hash-Table References
    ... I'm sure this conversation has hit this board a few times before, ... stop me if I'm posting an old idea: ... (defun access-array (stream char arg) ...
    (comp.lang.lisp)
  • Re: RAW_INPUT
    ... The raw_inputfunction writes out the arg and then ... waits for *user input*, and that is considered terminated when you hit ... Since you only hit return without typing 'Josh' first you get an empty ... Prev by Date: ...
    (comp.lang.python)