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?

Thanks,
-a

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

Reply via email to