Is it just Syntactic Sugar ?
Johann Hibschman
johann at physics.berkeley.edu
Tue May 30 17:24:19 EDT 2000
Michael Hudson writes:
> Johann Hibschman <johann at physics.berkeley.edu> writes:
>> But then it loses its most basic utility, namely working with
>> integers. An integer is not a mutable type.
>>
>> A simple rewrite is the only way to make sense of
>>
>> i += 1 -> i = i + 1
>>
>> if i is an integer, given the existing python variable semantics.
> But it's not the only way to make sense of
> a.b.c[item(d)] += e
> which you'd like to be roughly equivalent to
> t1 = a.b.c
> t2 = item(d)
> t1[t2] = t1[t2] + e
> or
> a.b.c.__add_item__(item(d),e)
> depending on whether a.b.c is an instance that implement the
> appropriate magic or not.
Ah, I see. That's true. I would rather see a macro-like definition
as you outlined first, with some python equivalent of gensym. Yes.
Hmm.
I still see this as a macro-like method. And, yes, what you've
outlined does seem like the proper way to expand the macro, will full
gensym-ing and all. But it still calls the simple "+" operator on the
object returned by t1[t2], not some form of t1[t2].incr(e), which is
what I'd understood Thomas Wouters to be asking for.
--Johann
--
Johann Hibschman johann at physics.berkeley.edu
More information about the Python-list
mailing list