Playing with Prothon today, I am fascinated by the idea of eliminating
classes in Python. I'm trying to figure out what fundamental benefit
there is to having classes. Is all this complexity unecessary?
Here is an example of a Python class with all three types of methods
(instance, static, and class methods).
# Example from Ch.23, p.381-2 of Learning Python, 2nd ed.
class Multi:
numInstances = 0
def __init__(self):
Multi.numInstan ces += 1
def printNumInstanc es():
print "Number of Instances:", Multi.numInstan ces
printNumInstanc es = staticmethod(pr intNumInstances )
def cmeth(cls, x):
print cls, x
cmeth = classmethod(cme th)
a = Multi(); b = Multi(); c = Multi()
Multi.printNumI nstances()
a.printNumInsta nces()
Multi.cmeth(5)
b.cmeth(6)
Here is the translation to Prothon.
Multi = Object()
with Multi:
.numInstances = 0
def .__init__(): # instance method
Multi.numInstan ces += 1
def .printNumInstan ces(): # static method
print "Number of Instances:", Multi.numInstan ces
def .cmeth(x): # class method
print Multi, x
a = Multi(); b = Multi(); c = Multi()
Multi.printNumI nstances()
a.printNumInsta nces()
Multi.cmeth(5)
b.cmeth(6)
Note the elimination of 'self' in these methods. This is not just a
syntactic shortcut (substiting '.' for 'self') By eliminating this
explicit passing of the self object, Prothon makes all method forms
the same and eliminates a lot of complexity. It's beginning to look
like the complexity of Python classes is unecessary.
My question for the Python experts is -- What user benefit are we
missing if we eliminate classes?
-- Dave
Jul 18 '05
145 6383
In article <AHF9c.49048$cx 5.33872@fed1rea d04>,
Mark Hahn <ma**@prothon.o rg> wrote: I didn't know I was going the opposite direction from Python. I guess I'll have to change that.
I guess I didn't make it clear that no design decisions were frozen in the language.
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet?
--
Aahz (aa**@pythoncra ft.com) <*> http://www.pythoncraft.com/
"usenet imitates usenet" --Darkhawk
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Michael wrote:
| They're planning to remove tab indention support in 3.0? I for one
| would be pissed off at such a change. I don't mind people using
| spaces if they like but I see no reason I shouldn't be able to use
| tabs if I like. I can't see how it should make any difference to
| Python which you use so why not allow for personal preference?
|
|> I'll just mention that there are ***very good***, that is
|> ***extremely good*** reasons why the Python standard is to use
|> spaces for indentation, and why the option of using tabs will be
|> removed in 3.0.
|>
They can't possibly be good enough (for my needs). That said, where
can I check this. I don't want to make important decisions on
incomplete information.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFAaO9xE1g uSVL8NK8RAuZCAJ 9k2jZSLxwG6Ql3r HqV8u5APcuPJgCg hjjo
AW0ROHktFKNbSKS WYn1q9BM=
=AR/9
-----END PGP SIGNATURE-----
A2. People that bitch about top-posting.
"Aahz" <aa**@pythoncra ft.com> wrote in message
news:c4******** **@panix2.panix .com... In article <AHF9c.49048$cx 5.33872@fed1rea d04>, Mark Hahn <ma**@prothon.o rg> wrote: I didn't know I was going the opposite direction from Python. I guess
I'llhave to change that.
I guess I didn't make it clear that no design decisions were frozen in
thelanguage. A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet? -- Aahz (aa**@pythoncra ft.com) <*>
http://www.pythoncraft.com/ "usenet imitates usenet" --Darkhawk
> but you could allow either all-tabs or all-spaces in a given file.
Maybe that the is most sensible solution I've heard yet.
"Greg Ewing (using news.cis.dfn.de )" <ie*******@snea kemail.com> wrote in
message news:40******** ******@sneakema il.com... Mark Hahn wrote: > Prothon has announced that we are caving in and going to spaces instead
of > tabs, even though both of the Prothon authors abhor spaces.
You don't have to choose between them if you don't want to. Disallowing *mixed* tabs and spaces is sensible, but you could allow either all-tabs or all-spaces in a given file.
-- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand http://www.cosc.canterbury.ac.nz/~greg but you could allow either all-tabs or all-spaces in a given file.
Maybe that the is most sensible solution I've heard yet.
That'd seem agreeable to me. Especially if how strict the rule was could
be set at run time as a Python argument. So you could either have mixed
spaces and tabs refuse to run, give an error, or be ignored and run (if
possible) as we might currently expect. but you could allow either all-tabs or all-spaces in a given file.
Maybe that the is most sensible solution I've heard yet.
That'd seem agreeable to me. Especially if how strict the rule was could
be set at run time as a Python argument. So you could either have mixed
spaces and tabs refuse to run, give an error, or be ignored and run (if
possible) as we might currently expect.
"Mark Hahn" <ma**@prothon.o rg> wrote in message
news:9C8ac.6830 3$cx5.4075@fed1 read04... but you could allow either all-tabs or all-spaces in a given file. Maybe that the is most sensible solution I've heard yet.
That mostly works. In fact, the original suggestion to use
tabs followed by spaces *only* for alignining continuations
also works: the most toxic case is the one where someone
has their indentation set to 4, and the editor blithely compresses
runs of 8 spaces to one tab. Then it goes to someone
else whose editor is set up for four character tabs, and
the indentation gets messed up.
John Roth
PS - I may have gotten several private e-mails at the address
on these postings. Please don't - the address that's availible
on Usenet is virus checked, spam checked and then deleted
without being read.
JR.
"Greg Ewing (using news.cis.dfn.de )" <ie*******@snea kemail.com> wrote in message news:40******** ******@sneakema il.com... Mark Hahn wrote: > Prothon has announced that we are caving in and going to spaces
instead of > tabs, even though both of the Prothon authors abhor spaces.
You don't have to choose between them if you don't want to. Disallowing *mixed* tabs and spaces is sensible, but you could allow either all-tabs or all-spaces in a given file.
-- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand http://www.cosc.canterbury.ac.nz/~greg
John Roth wrote: As far as rendering programs, the most obvious culprit is OE, which for all of its defects and security problems, is still one of the most used mail and newsgroup clients out there.
<pre>
T h e r e i s a s o l u t i o n ; - )
</pre>
Gerrit.
--
Weather in Twenthe, Netherlands 30/03 13:55 UTC:
15.0°C wind 5.8 m/s E (57 m above NAP)
--
here will soon be Gerrit Holl's very own signature
Mark Hahn wrote: A2. People that bitch about top-posting.
Mark - I really find it a bit difficult to read your postings. I keep
scrolling to below to see whether there is still more to come - because you
do sometimes quote others and then answer below. When I see quoting in a
message, I automatically assume there's more to come, and I am not the
only one. I think it is the wrong answer to say that people shouldn't
bitch about top-posting - it _does_ annoy people (including me and Aahz).
There are conventions on usenet (and mailing lists), and they are there
with reason. I would like to kindly ask you to try to do more
'bottom-posting'. It makes your postings easier and prettier to read.
Really, it does - please try it...
yours,
Gerrit.
--
Weather in Twenthe, Netherlands 30/03 13:55 UTC:
15.0°C wind 5.8 m/s E (57 m above NAP)
--
here will soon be Gerrit Holl's very own signature
The irony of this idiocy is that is shows precisely why top-posting is bad.
"Mark Hahn" <ma**@prothon.o rg> wrote in message
news:Sz8ac.6827 2$cx5.62681@fed 1read04... A2. People that bitch about top-posting.
"Aahz" <aa**@pythoncra ft.com> wrote in message news:c4******** **@panix2.panix .com... In article <AHF9c.49048$cx 5.33872@fed1rea d04>, Mark Hahn <ma**@prothon.o rg> wrote: I didn't know I was going the opposite direction from Python. I guess I'llhave to change that.
I guess I didn't make it clear that no design decisions were frozen in thelanguage.
A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet? -- Aahz (aa**@pythoncra ft.com) <*> http://www.pythoncraft.com/ "usenet imitates usenet" --Darkhawk
-- http://mail.python.org/mailman/listinfo/python-list This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mark Hahn |
last post by:
I would like to announce a new interpreted object-oriented language very
closely based on Python, that is Prototype-based, like Self
(http://research.sun.com/research/self/language.html) instead of class-based
like Python.
I have named the language Prothon, short for PROtotype pyTHON. You can
check it out at http://prothon.org.
The prototype scheme makes object oriented computing very simple and
complicated things like meta-classes...
|
by: Mark Hahn |
last post by:
Ben Collins and I have developed a new interpreted object-oriented language
very closely based on Python, that is Prototype-based, like Self
(http://research.sun.com/research/self/language.html) instead of class-based
like Python.
I have named the language Prothon, short for PROtotype pyTHON. You can
check it out at http://prothon.org.
The prototype scheme makes object oriented computing very simple and
complicated things like...
|
by: David MacQuigg |
last post by:
I'm concerned that with all the focus on obj$func binding, &closures,
and other not-so-pretty details of Prothon, that we are missing what
is really good - the simplification of classes. There are a number of
aspects to this simplification, but for me the unification of methods
and functions is the biggest benefit.
All methods look like functions (which students already understand).
Prototypes (classes) look like modules. This will...
|
by: Michele Simionato |
last post by:
So far, I have not installed Prothon, nor I have experience with Io, Self
or other prototype-based languages. Still, from the discussion on the
mailing list, I have got the strong impression that you do not actually
need to fork Python in order to implement prototypes. It seems to me
that Python metaclasses + descriptors are more than powerful enough to
implementing prototypes in pure Python.
I wrote a module that implements part of what...
|
by: Mark Hahn |
last post by:
As we are addressing the "warts" in Python to be fixed in Prothon, we have
come upon the
mutable default parameter problem. For those unfamiliar with the problem,
it can be seen in this Prothon code sample where newbies expect the two
function calls below to both print :
def f( list= ):
print list.append!(1)
f() # prints
| |
by: Mark Hahn |
last post by:
Prothon is pleased to announce another major release of the language,
version 0.1.2, build 710 at http://prothon.org.
This release adds many new features and demonstrates the level of maturity
that Prothon has reached. The next release after this one in approximately
a month will be the first release to incorporate the final set of frozen
Prothon 1.0 language features and will be the Alpha release. You can see
the set of features still...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |