Pascal int()

Jason Stokes jstok at bluedog.apana.org.au
Wed Mar 22 02:53:35 EST 2000


In article <868zzfydwr.fsf at g.local>, Gareth McCaughan
<Gareth.McCaughan at pobox.com> wrote:

> Jason Stokes wrote:
> 
> > If, like Smalltalk or Lisp, there was a syntax for passing a name or symbol
> > as an argument instead of a reference to an object, it would be possible to
> > write a Pascal style inc() function.
> 
> I'm no Smalltalk expert, but I don't think there's any way
> to write a Lisp function such that
> 
>   (let ((a 1))
>     (try-to-increment a)
>     a)
> 
> will return anything other than 1. Or even
> 
>   (let ((a 1))
>     (try-to-increment 'a)
>     a)
> 
> which "quotes" A and passes the symbol instead of its value.


I'm no Lisp expert, but I believe that "set" could be used for this.  Eg:

(defun increment (symbol)
    (set symbol 
       (add1 (eval (symbol)))
    ) 
)

(let ((a 1))
   (increment 'a)
   a)



More information about the Python-list mailing list