Guide to the python interp. source?

Tim Gahnström /Bladerman tim at bladerman.com
Sun Jul 28 15:23:51 EDT 2002


"Martin v. Loewis" <martin at v.loewis.de>
> "Tim Gahnström /Bladerman" <tim at bladerman.com> writes:
>
> > when it comes to calling functions it will look like this
> >
> > def setTo3(x):
> >     x=3
> >
> > a=2
> > setTo3(a)
>
> Others have already suggested that this will be impossible to
> implement, but I guess I can't stop you from trying, so I won't.
>
> Instead, I suggest that this is already possible with a slightly
> different notation

I must say thankyou verry much!!!

Not maybe for the solution, but for the effort to see solution instead of
just trying to spot things that make it "impossible"
It is fairly rare that you stumble upon such people (just try to talk to a
random university professor :-))


> class Reference:
>   def __init__(self, value): self.value = value
>   def assign(self, value): self.value = value

The solution you outlined will ofcourse work for this particular example,
but the problem is that I want all this mess to be invissible to the user.
But maybe I can use it anyway. As I have said several times, I havn't yet
gotten aquainted with everything yet som maybe this is not possible.

The thing I have on my mind is (maybe this is what you meant to) that maybe
I can change the parser a little so that it sees everything as a subclass of
Refference. Then I just change the asignmentpart of the interpreter to use
.assign() instead of whatever hapens now.

I really have a hard time to explain what I mean here but I think I want a
statement like this:
a=2
to be parsed to
a.assign(Refference(2))

Do you think a solution like that be possible?
Anyway, even if this doesn't work out I am very gretfull for your effort to
see a solution to a tricky problem.
A problem might ofcourse be that this will screw the possibilities to use
the python library wich is not an option...

Tim





More information about the Python-list mailing list