473,748 Members | 7,118 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PEP Proposal

Hi,

sorry, I have these ideas for longer than 10 years, please have a look on it
and comment on it. Thx.
----

This is another proposal for introducing types into Python.

There are many reasons for incorporating types into Python, but there is
also a lot of concern about doing so because of destroying the original
character of Python as a smart script language.

This proposal adds several advantages of Prolog(ue) techniques without
changing the natural understanding of Python as a language.
Proposal:

1. Method definitions can be non-unique if a type is prefixed to one or more
of its parameters, or the parameters differ in number.

2. A keyword 'reject' is added.

3. A keyword 'fail' is added.

4. A keyword 'cut' is added.
Definition:

1. A "type" is a String naming the actual class or class family which the
passed instanced is derived from, prefixing the parameter.

2. "'reject'" is a marker inside a function/method and signals that further
processing will not be done inside this method, but instead be passed to the
next available function/method in row, otherwise an implicit "fail" will
occur.

3. "'fail'" is a marker inside a function/method and signals that NO further
processing can be done in neither of this or the following
functions/methods.

4. "'cut'" is a marker inside a function/method that signals that the
failure of called functions/methods inside of it, following this statement,
automatically lead to a failure, instead of trying the next method -
normally, it would be "reject" instead.

5. Failure of functions/methods to outside of this new context are signalled
with a new exception e.g. "MethodRetrialE rror".

E.g.

def whoisthethief(" List" x):
return iknowit(x)

def whoisthethief(" String" x, "String" y):
return iknowit([x,y])

##########

def numeral_add(a, b):
if type(a)!=types. IntType:
reject
...

# equivalent to:

def numeral_add("In teger" a, b):
...
Sep 25 '08 #1
7 1067
En Thu, 25 Sep 2008 16:24:58 -0300, <py********@arc or.deescribió:
sorry, I have these ideas for longer than 10 years, please have a look
on it
and comment on it. Thx.

This is another proposal for introducing types into Python.
You got the terminology wrong. Python had "types" from the very start.
You're talking about some kind of generic functions, or an alternative
dispatch method.

Read this GvR blog post [1] and his next one; also see PEP 3124 by Phillip
J. Eby, who wrote a pretty good implementation of generic functions a long
time ago.

Your proposal requires a syntax change and three new keywords; all the
others achieve roughly equivalent results without requiring any change to
the core language.

[1] http://www.artima.com/weblogs/viewpo...?thread=155123

--
Gabriel Genellina

Sep 25 '08 #2
Gabriel Genellina wrote:
En Thu, 25 Sep 2008 16:24:58 -0300, <py********@arc or.deescribió:
>sorry, I have these ideas for longer than 10 years, please have a look
on it
and comment on it. Thx.

This is another proposal for introducing types into Python.

You got the terminology wrong. Python had "types" from the very start.
You're talking about some kind of generic functions, or an alternative
dispatch method.
Typed parameters. Method-Declaration-filtered-typed parameters. That's what
I'm thinking of.

I hear & I will answer.
Sep 25 '08 #3
On Sep 25, 12:24 pm, python-...@arcor.de wrote:
def whoisthethief(" List" x):
return iknowit(x)

def whoisthethief(" String" x, "String" y):
return iknowit([x,y])
I dunno if this is very Pythonic in nature, but I've done things like
rebinding methods dynamically.

ex:
>>def test(a):
.... return a * 2
....
>>print test(2)
4
>>def test2(b):
.... return b * 3
....
>>test = test2
print test(2)
6

In your case

def myNewThiefIdent ifier(x,y):
return "Dunno"

whoisthethief = myNewThiefIdent ifier
Which method would this affect (i.e. which 'whoisthethief' )?

I assume you could figure it out, given a match on the signature, but
how much work would this require from the developer and the
interpreter?

(apologies in case Google Groups decide to multipost)
Sep 25 '08 #4
py********@arco r.de schrieb:
Gabriel Genellina wrote:
>En Thu, 25 Sep 2008 16:24:58 -0300, <py********@arc or.deescribió:
>>sorry, I have these ideas for longer than 10 years, please have a look
on it
and comment on it. Thx.

This is another proposal for introducing types into Python.
You got the terminology wrong. Python had "types" from the very start.
You're talking about some kind of generic functions, or an alternative
dispatch method.

Typed parameters. Method-Declaration-filtered-typed parameters. That's what
I'm thinking of.

I hear & I will answer.
Did you bother reading the pointers Gabriel gave to you? RuleDispatch or
other generic method dispatches exists for about as long as you ponder
about them.

Diez
Sep 25 '08 #5
On Sep 25, 4:04*pm, "Gabriel Genellina" <gagsl-...@yahoo.com.a r>
wrote:
En Thu, 25 Sep 2008 16:24:58 -0300, <python-...@arcor.deesc ribió:
sorry, I have these ideas for longer than 10 years, please have a look *
on it
and comment on it. Thx.
This is another proposal for introducing types into Python.

You got the terminology wrong. Python had "types" from the very start. *
You're talking about some kind of generic functions, or an alternative *
dispatch method.

Read this GvR blog post [1] and his next one; also see PEP 3124 by Phillip *
J. Eby, who wrote a pretty good implementation of generic functions a long *
time ago.

Your proposal requires a syntax change and three new keywords; all the *
others achieve roughly equivalent results without requiring any change to*
the core language.

Just to play Devil's advocate here, multimethods(** ) aren't
equivalent, roughly or otherwise, to what the OP is requesting.
Superficially it looks that way, but the actual use case for this
logic programming is something that ordinary multimethods can't do.

Prolog-style programming is sort of the exact opposite of pure
functional programming. Whereas in pure functional programming there
are no side effects, in Prolog pretty much everything is a side
effect. The way things happen in Prolog is execution of side effects
in the process of searching for pattern matches.

A decent multimethod implementation doesn't use trial and error for
dispatch; it'll use some kind of mapping and cacheing to get to the
appropriate function as quickly as possible. In logic programming
however, the trial-and-error is essential since side-effects can and
are supposed to happen in the process of trying.
Anyway, this proposal can easily be implemented more or less as
proposed without any syntax changes, using the same ideas as the
multimethod implementations , but guaranteeing trial-and-error
dispatching.
Carl Banks

(**) I avoid the term "generic function" since it constrasts starkly
with the use of the word "generic" in generic programming.
Sep 25 '08 #6
On Fri, Sep 26, 2008 at 6:14 AM, <py********@arc or.dewrote:
Typed parameters. Method-Declaration-filtered-typed parameters. That's what
I'm thinking of.
Why do we need this (rubbish) ?
Seriously. The use-case is far too small.
And don't invent use-cases either.

Instead of coming up with ideas of adding more
and more into the language from other languages
of which certain features weren't very good in
the first place, devote your time to improving
the libraries, documentation, etc.

Typed parameters is useless to me. A lot of
developers would agree.

--JamesMills

--
--
-- "Problems are solved by method"
Sep 25 '08 #7
On Sep 25, 2:24*pm, python-...@arcor.de wrote:
Hi,

sorry, I have these ideas for longer than 10 years, please have a look onit
and comment on it. Thx.

----

This is another proposal for introducing types into Python.

There are many reasons for incorporating types into Python, but there is
also a lot of concern about doing so because of destroying the original
character of Python as a smart script language.

This proposal adds several advantages of Prolog(ue) techniques without
changing the natural understanding of Python as a language.

Proposal:

1. Method definitions can be non-unique if a type is prefixed to one or more
of its parameters, or the parameters differ in number.

2. A keyword 'reject' is added.

3. A keyword 'fail' is added.

4. A keyword 'cut' is added.

Definition:

1. A "type" is a String naming the actual class or class family which the
passed instanced is derived from, prefixing the parameter.

2. "'reject'" is a marker inside a function/method and signals that further
processing will not be done inside this method, but instead be passed to the
next available function/method in row, otherwise an implicit "fail" will
occur.

3. "'fail'" is a marker inside a function/method and signals that NO further
processing can be done in neither of this or the following
functions/methods.

4. "'cut'" is a marker inside a function/method that signals that the
failure of called functions/methods inside of it, following this statement,
automatically lead to a failure, instead of trying the next method -
normally, it would be "reject" instead.

5. Failure of functions/methods to outside of this new context are signalled
with a new exception e.g. "MethodRetrialE rror".

E.g.

def whoisthethief(" List" x):
* return iknowit(x)

def whoisthethief(" String" x, "String" y):
* return iknowit([x,y])

##########

def numeral_add(a, b):
* if type(a)!=types. IntType:
* * reject
* ...

# equivalent to:

def numeral_add("In teger" a, b):
* ...
Would you settle for a class or classes which had the same
functionality, only you would call its methods with parentheses?

Modified examples:

@argtype( List )
def whoisthethief(x ):
return iknowit(x)

@argtype( String, String )
def whoisthethief(x , y):
return iknowit([x,y])

def numeral_add(a, b):
if type(a)!=types. IntType:
reject()
...

/or:

def numeral_add(a, b):
if type(a)!=types. IntType:
flow.reject()
...
Sep 26 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1708
by: Guido van Rossum | last post by:
Robert and Python-dev, I've read the J2 proposal up and down several times, pondered all the issues, and slept on it for a night, and I still don't like it enough to accept it. The only reason to accept it would be to pacify the supporters of the proposal, and that just isn't a good enough reason in language design. However, it got pretty darn close! I'm impressed with how the community managed to pull together and face the enormous...
21
2418
by: Mike Meyer | last post by:
PEP: XXX Title: A rational number module for Python Version: $Revision: 1.4 $ Last-Modified: $Date: 2003/09/22 04:51:50 $ Author: Mike Meyer <mwm@mired.org> Status: Draft Type: Staqndards Content-Type: text/x-rst Created: 16-Dec-2004 Python-Version: 2.5
15
2596
by: Ralf W. Grosse-Kunstleve | last post by:
****************************************************************************** This posting is also available in HTML format: http://cci.lbl.gov/~rwgk/python/adopt_init_args_2005_07_02.html ****************************************************************************** Hi fellow Python coders, I often find myself writing:: class grouping:
13
2061
by: Ian Hickson | last post by:
A group of us have been unofficially working on a proposal of extensions to HTML4's Forms chapter, and would like to get input from a wider range of people now that we think our draft proposal is reaching a stable stage: http://www.whatwg.org/specs/web-forms/2004-06-27-call-for-comments/ Some of the features we are proposing include new input control types for dates, times, e-mail addresses, and numbers; a new client-side validation...
4
2735
by: wkaras | last post by:
I would like to propose the following changes to the C++ Standard, the goal of which are to provide an improved ability to specify the constraints on type parameters to templates. Let me say from the start that my knowledge of compiler implementation is very limited. Therefore, my suggestions may have to be rejected because they are difficult or impossible to implement. The proposal is based on the concept of "type similarity". Type...
0
1278
by: jygoh3 | last post by:
ENCYCLOPEDIA OF MOBILE COMPUTING & COMMERCE CALL FOR SHORT ARTICLES Proposal Deadline: 15 Nov 2005 (Extended)
47
3361
by: Pierre Barbier de Reuille | last post by:
Please, note that I am entirely open for every points on this proposal (which I do not dare yet to call PEP). Abstract ======== This proposal suggests to add symbols into Python. Symbols are objects whose representation within the code is more important than their actual value. Two symbols needs only to be
10
3308
by: =?iso-8859-2?B?SmFuIFJpbmdvuQ==?= | last post by:
Hello everybody, this is my first post to a newsgroup at all. I would like to get some feedback on one proposal I am thinking about: --- begin of proposal --- Proposal to add signed/unsigned modifier to class declarations to next revision of C++ programming language
12
2765
by: Ioannis Vranos | last post by:
Perhaps a mechanism can be introduced in the C++0x/1x standard, something simple like defining a function as: void somefunc(void) throw() { // ... }
56
6742
by: Adem | last post by:
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" The C++ Standard (ISO/IEC 14882, Second edition, 2003-10-15) says under 6.4.2(2) : case constant-expression : I propose that the case expression of the switch statement be changed from "integral constant-expression" to "integral expression".
0
8984
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8823
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9312
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,...
0
9238
tracyyun
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...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4593
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...
0
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.