What other languages use the same data model as Python?

Ian Kelly ian.g.kelly at gmail.com
Thu May 5 15:13:11 EDT 2011


On Thu, May 5, 2011 at 10:58 AM, harrismh777 <harrismh777 at charter.net> wrote:
> Grant Edwards wrote:
>>
>> That's what I was trying to say, but probably not as clearly.  The "&"
>> operatore returnas a_value_  that the OP passes_by_value_  to a
>> function.  That function then uses the "*" operator to use that value
>> to access some data.
>
> I'm gonna try a D'Aprano-style bogus argument for a moment...
>
> ... saying that 'C' does not support pass-by-reference because you have to
> direct the compiler with the '&' and '*' characters is a little like saying
> that
>
>     Python does not support decorations ! ...
>
>
> ...  because you have to direct the interpreter with some
>
>
> @ bogus-decorator-syntax
>
>
>     I want Python to support decorations automatically !

It seems to me that manually referencing and dereferencing in C is
more akin to decorating functions like this:

def foo(x):
    do_stuff()

foo = decorate(foo)

On the other hand, the @ syntax is analogous to declaring reference
types in C++ (e.g. "int &" as opposed to "int *").  In both cases you
have to tell the interpreter / compiler that you want to use the
decoration / pass-by-reference feature, and the actual work is done
for you automatically.



More information about the Python-list mailing list