472,356 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,356 software developers and data experts.

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. "MethodRetrialError".

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("Integer" a, b):
...
Sep 25 '08 #1
7 1002
En Thu, 25 Sep 2008 16:24:58 -0300, <py********@arcor.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********@arcor.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 myNewThiefIdentifier(x,y):
return "Dunno"

whoisthethief = myNewThiefIdentifier
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********@arcor.de schrieb:
Gabriel Genellina wrote:
>En Thu, 25 Sep 2008 16:24:58 -0300, <py********@arcor.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.ar>
wrote:
En Thu, 25 Sep 2008 16:24:58 -0300, <python-...@arcor.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.

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********@arcor.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. "MethodRetrialError".

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("Integer" 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
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...
21
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...
15
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...
13
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...
4
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...
0
by: jygoh3 | last post by:
ENCYCLOPEDIA OF MOBILE COMPUTING & COMMERCE CALL FOR SHORT ARTICLES Proposal Deadline: 15 Nov 2005 (Extended)
47
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...
10
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...
12
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
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...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

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.