From: Leslie P. Polzer
Subject: Arithmetics in alist
Date: 
Message-ID: <1183040422.349424.282540@k79g2000hse.googlegroups.com>
The configuration of my program shall be stored in an alist:

  (defconstant *config* '((xres . 640) (yres . 480)))

which works fine.

However, I would like to set some properties dynamically:

  (defconstant *config* '((xres . 640) (yres . (- 400 50) )))

This obviously doesn't work.

I mucked around quite a bit with backtick quoting and the comma quote,
but I don't seem to have a deep enough understanding to fit them in
here...

  Leslie

From: Rainer Joswig
Subject: Re: Arithmetics in alist
Date: 
Message-ID: <joswig-38AFA5.16363028062007@news-europe.giganews.com>
In article <························@k79g2000hse.googlegroups.com>,
 "Leslie P. Polzer" <·············@gmx.net> wrote:

> The configuration of my program shall be stored in an alist:
> 
>   (defconstant *config* '((xres . 640) (yres . 480)))
> 
> which works fine.
> 
> However, I would like to set some properties dynamically:
> 
>   (defconstant *config* '((xres . 640) (yres . (- 400 50) )))
> 
> This obviously doesn't work.
> 
> I mucked around quite a bit with backtick quoting and the comma quote,
> but I don't seem to have a deep enough understanding to fit them in
> here...
> 
>   Leslie

'(foo . 100) -> (CONS 'foo 100)

'((foo . 100) (bar . 200))  -> (list (cons 'foo 100) (cons 'bar 200))

So:

(list (cons 'xres 640) (cons 'yres (- 400 50)))


See also

`((xres . 640) (yres . ,(- 400 50)))

or at readtime (if read eval is enabled):

'((xres . 640) (yres . #.(- 400 50)))

-- 
http://lispm.dyndns.org
From: Leslie P. Polzer
Subject: Re: Arithmetics in alist
Date: 
Message-ID: <1183041925.151713.142330@o61g2000hsh.googlegroups.com>
On Jun 28, 4:36 pm, Rainer Joswig <······@lisp.de> wrote:

> See also
>
> `((xres . 640) (yres . ,(- 400 50)))

I guess I was almost there...

Thanks for the elaborate explanation!
From: Leslie P. Polzer
Subject: Re: Arithmetics in alist
Date: 
Message-ID: <1183045186.186513.173750@u2g2000hsc.googlegroups.com>
On Jun 28, 4:36 pm, Rainer Joswig <······@lisp.de> wrote:

> See also
>
> `((xres . 640) (yres . ,(- 400 50)))
>
> or at readtime (if read eval is enabled):
>
> '((xres . 640) (yres . #.(- 400 50)))

Hmmm, neither of those work in SBCL:


CL-USER(29): `((xres . 640) (yres . ,(- 400 50)))

debugger invoked on a COMMON-LISP:READER-ERROR in thread #<THREAD
"initial thread" {A815409}>:
  READER-ERROR at 34 (line 1, column 34) on #<SB-IMPL::STRING-INPUT-
STREAM {B0A2E31}>:
More than one object follows . in list.

Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

(SB-IMPL::%READER-ERROR
 #<SB-IMPL::STRING-INPUT-STREAM {B0A2E31}>
 "More than one object follows . in list.")
0] 0

Same error with the second expression.

  Leslie
From: Rainer Joswig
Subject: Re: Arithmetics in alist
Date: 
Message-ID: <joswig-EB7557.18150728062007@news-europe.giganews.com>
In article <························@u2g2000hsc.googlegroups.com>,
 "Leslie P. Polzer" <·············@gmx.net> wrote:

> On Jun 28, 4:36 pm, Rainer Joswig <······@lisp.de> wrote:
> 
> > See also
> >
> > `((xres . 640) (yres . ,(- 400 50)))
> >
> > or at readtime (if read eval is enabled):
> >
> > '((xres . 640) (yres . #.(- 400 50)))
> 
> Hmmm, neither of those work in SBCL:
> 
> 
> CL-USER(29): `((xres . 640) (yres . ,(- 400 50)))
> 
> debugger invoked on a COMMON-LISP:READER-ERROR in thread #<THREAD
> "initial thread" {A815409}>:
>   READER-ERROR at 34 (line 1, column 34) on #<SB-IMPL::STRING-INPUT-
> STREAM {B0A2E31}>:
> More than one object follows . in list.


Works for me (SBCL 1.0.5):

* `((xres . 640) (yres . ,(- 400 50)))
((XRES . 640) (YRES . 350))


> 
> Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.
> 
> restarts (invokable by number or by possibly-abbreviated name):
>   0: [ABORT] Exit debugger, returning to top level.
> 
> (SB-IMPL::%READER-ERROR
>  #<SB-IMPL::STRING-INPUT-STREAM {B0A2E31}>
>  "More than one object follows . in list.")
> 0] 0
> 
> Same error with the second expression.
> 
>   Leslie

Works, too.

* '((xres . 60) (yres . #.(- 400 50)))
((XRES . 60) (YRES . 350))


* Which SBCL version are using?
* How are you using SBCL (Terminal, SLIME, ...)?
* Do you have a special setup for SBCL?

-- 
http://lispm.dyndns.org
From: Leslie P. Polzer
Subject: Re: Arithmetics in alist
Date: 
Message-ID: <1183057326.290347.242750@m36g2000hse.googlegroups.com>
On Jun 28, 6:15 pm, Rainer Joswig <······@lisp.de> wrote:

> * Which SBCL version are using?

SBCL 0.9.14


> * How are you using SBCL (Terminal, SLIME, ...)?

Terminal with Linedit (see my rc file below)


> * Do you have a special setup for SBCL?

(require 'asdf)
(require 'asdf-install)

(when (interactive-stream-p *terminal-io*)
  (require :sb-aclrepl)
  (require :linedit)
  (funcall (intern "INSTALL-REPL" :linedit) :wrap-current t))

Leslie
From: Rainer Joswig
Subject: Re: Arithmetics in alist
Date: 
Message-ID: <joswig-7706E4.21263228062007@news-europe.giganews.com>
In article <························@m36g2000hse.googlegroups.com>,
 "Leslie P. Polzer" <·············@gmx.net> wrote:

> On Jun 28, 6:15 pm, Rainer Joswig <······@lisp.de> wrote:
> 
> > * Which SBCL version are using?
> 
> SBCL 0.9.14
> 
> 
> > * How are you using SBCL (Terminal, SLIME, ...)?
> 
> Terminal with Linedit (see my rc file below)
> 
> 
> > * Do you have a special setup for SBCL?
> 
> (require 'asdf)
> (require 'asdf-install)
> 
> (when (interactive-stream-p *terminal-io*)
>   (require :sb-aclrepl)
>   (require :linedit)
>   (funcall (intern "INSTALL-REPL" :linedit) :wrap-current t))
> 
> Leslie

I'm no expert on that. You might want to ask on the SBCL list.
Also getting a newer SBCL could be a good idea anyway.
SBCL 1.0.7 is just out...
http://sourceforge.net/project/showfiles.php?group_id=1373

-- 
http://lispm.dyndns.org