how much does Python model my Compsci course?

D-Man dsh8290 at rit.edu
Thu May 31 14:10:49 EDT 2001


On Thu, May 31, 2001 at 12:55:34PM -0400, Roy Katz wrote:
| Hello!
| 
| I just finished this semester a course on programming language
| implementation (I'm a junior in comp. engineering at the University of
| Maryland in College Park, MD). Anyhow, many interesting topics were
| covered -- non-deterministic finite automata, DFA's,
| context-sensitive grammars, grammar productions, param
| passing, function implementation, arrays.  

Most if not all of it applies to any language.   Understanding the quirks of the
language can be easier after you understand the tradeoffs and
interactions involved with designing and implementing a language.

| Last year I asked here wether Python uses pass-by-reference;  Then I
| learned that there are four or five major types of param passing
| (the others being pass-by-{name,result,value,value-result}).  But
| Python looks as if it has invented a new form to (perhaps a
| variation on pass-by-ref) param passing, based on whether or not the
| object passed in is mutable (from what I understand...?)

It uses pass-by-value-reference just like Java does with Objects and
C/C++ with pointers and references (the difference is C and C++ are
explicit about it wrt to type declarations).  It passes the reference
by value.  (Or, as Grant Edwards put it, it is pass by value, but the
value is a reference)  If the object referred to is immutable (like
java.lang.String, for example), then there is no way to change the
data the reference (the client has) refers to.  You can't change the
reference because it was passed by value (like a pointer in C/C++ --
you can't change where it points to if it is an argument).  If the
object is mutable, then you can change the value that is referred to.

-D





More information about the Python-list mailing list