Andrew Lentvorski wrote:
> Recently, I've been using a package called MyHDL (a hardware description
> language using Python), I like it, but it has one particular wart that
> bites me a lot.
> 
> As a guy who uses HDL's, I'm used to things like (yeah, I do verilog,
> does it show?):
> 
> a = b;
> a <= b;
> 
> Which basically "connects" b to a.  The terminology isn't that important
> as to what "connects" means.
> 
> What MyHDL does is:
> 
> a.next = b
> 
> No big deal, right.  Well...  This means that:
> 
> a = b
> 
> is generally an error.  The problem: you can't actually flag this.
> Assignment in python isn't operating on objects, it's operating on the
> namespace dictionary.
> 
> What you really want is:
> 
> a = SomeClass()  # Just fine
> a.next = val     # Also just fine
> a = b            # Fail ...
> 
> This doesn't seem to be able to be done in Python.
> 
> Now C/C++ can do this via either a const pointer to non-const data (C)
> or by overloading with assignment operator of a class (C++).  However,
> it gets "lucky" simply because that function is built into the language.
> 
> So my question: What other languages *can* pull this off?
> 

I don't understand the question, prob. because I still don't grok what
"connects b to a" implies even after your saying 'a.next = b'.

A const pointer to non-const data in python would be, (eg) like a list,
no? .. A const pointer at least so long as you didn't "reassign" a.

a = [None]
a[0] = val

Or, in your object example

a = SomeClass()
a.next = val

I don't understand what you mean by
a = b # fail

IOW, I don't understand what a=b is intended to say or do (or declare?),
I gather it's not a real "assignment" or replacing the value of a.next
or copying objects as with 'a=copy.deepcopy(b)' or the other way around?

It all sounds interesting, if you could educate me a bit more. :-)

Regards,
..jim (educating me:possibly hopeless)

-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to