[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: a little help with basic elisp

From: Barry Margolin
Subject: Re: a little help with basic elisp
Date: Fri, 20 Feb 2015 02:39:04 -0500
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

In article <address@hidden>,
 Glen Stark <address@hidden> wrote:

> Hi everyone
> I'm having trouble with the basics of lisp, and I'd like some help 
> understanding and correcting what I am doing wrong in the following mce:
> (defun gas-push-sr-pair ()
>   "I want to add a apair consisting of a the string I prompted for at the 
> mini-buffer, and the string yo"
>   (interactive)
>   (let (to-string)
>       (setq to-string (read-from-minibuffer (concat (thing-at-point 
> 'symbol) " to: ")))
>       (add-to-list 'gas-sr-stack  '(to-string . "yo") )
>       )
>   )
> When I run this, and do   (insert (pop gas-sr-stack)), I get the 
> following:
>   gas-pop-word: Wrong type argument: char-or-string-p, (to-string . "yo")
> From this I can see that I probably can't insert a char-or-string-p.  I 

No, you can ONLY insert a char-or-string-p. It's telling you what type 
it's supposed to be. Since it wasn't, you got an error.

> guess I can figure that out -- it's not really part of my end goal 
> problem anyway.

> What's tripping me up is it seems that the values stored in the char-or-
> string-p are to-string and "yo".

(to-string . "yo") is a cons. Its car is the symbol to-string, its cdr 
is the string "yo". You can't insert a cons.

> I wanted to store the value which is currently in to-string, and "yo". 

When you quote something, you prevent evaluation of the contents. If you 
want to get the value of to-string, you have to access it without 

(add-to-list 'gas-sr-stack (cons to-string "yo"))

> Can someone please explain to me what I am doing wrong?  I'd like to 
> understand the language better, and of course solve my concrete problem.
> Cheers

Barry Margolin, address@hidden
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

reply via email to

[Prev in Thread] Current Thread [Next in Thread]