Yes, everything in Python is an object, but the language does not force you to code in the OO style (unlike e.g. Java).
Perl's object system was 'borrowed' from Python, so e.g. in both languages instance methods are just functions that take 'self' as the first parameter to access the object's state:
# Perl
sub get_name {
my ($self) = @_;
return $self->{name};
}
# Python
def get_name(self):
return self.name
| [reply] [d/l] |
Given the timing of the two -- python coming out in 91 -- it just wasn't that popular yet to have had a strong influence... but C++ has the same paradigm --
passing 'this' as the first param on the stack... Yet, how else would one do it where objects can have variable params. Is there a language that does it differently?
While I hadn't heard of python back in 91, I was using perl4. Perl5 came out in 94, 3 years later. While it could have been influenced by python, what other paradigm is there? I'd see both python and perl having derived such from C++, but maybe you were part of the design team and know something more from personal history? C++ had been around since the early-mid 80's and was already fairly well known and used (I'd used it, but integrating obj paradigms is still an ongoing work for me). So it seemed a more logical influence. Given perl's roots, I didn't give lisp much credit even though perl is closer to lisp than python...
If perl came from python, I'm surprised perl's obj system is so much more flexible (as others have compared it to lisp). I'll bet that lisp passed the "this" object
as the first list param as well...(?)...
| [reply] |
| [reply] |