Re: Python is DOOMED! Again!

2015-02-08 Thread Marko Rauhamaa
Ian Kelly : > On Sat, Feb 7, 2015 at 5:45 PM, Albert van der Horst > wrote: >> x -> x**2 >> instead of >> lambda x : x**2 > > Well, I don't think the existing syntax is incompatible with your > proposal. As it is, the -> token can only appear after the argument > list of a def statement, so there

Re: Python is DOOMED! Again!

2015-02-08 Thread Ian Kelly
On Sat, Feb 7, 2015 at 5:45 PM, Albert van der Horst wrote: > It is too bad `` -> '' as a token is now taken. > I wanted to propose to replace the ternary syntax > lambda .. : .. > by a regular operator > .. -> .. > then we could have > x -> x**2 > instead of > lambda x : x**2 Well, I don't th

Re: Python is DOOMED! Again!

2015-02-08 Thread Chris Angelico
On Sun, Feb 8, 2015 at 6:55 PM, Steven D'Aprano wrote: > If this were syntax, then the compiler could just as easily set the function > name from -> as from def. Lambda has the limitations that it has because it > is an expression, not because of magical "def" properties. True, it could, but it w

Re: Python is DOOMED! Again!

2015-02-08 Thread Steven D'Aprano
Chris Angelico wrote: > On Sun, Feb 8, 2015 at 11:45 AM, Albert van der Horst > wrote: >> def square(x): x**2 >> but >> square = x->x**2 >> >> or >> >> mult = x,y -> >>result = 0 >>for i in range(x): >> result +=y >>return result >> >> doing away with the ternary operator def >

Re: Python is DOOMED! Again!

2015-02-07 Thread Chris Angelico
On Sun, Feb 8, 2015 at 11:45 AM, Albert van der Horst wrote: > def square(x): x**2 > but > square = x->x**2 > > or > > mult = x,y -> >result = 0 >for i in range(x): > result +=y >return result > > doing away with the ternary operator def > > def .. ( .. ) : .. > > replacing it b

Re: Python is DOOMED! Again!

2015-02-07 Thread Albert van der Horst
In article , Ethan Furman wrote: >-=-=-=-=-=- > >On 01/21/2015 08:30 PM, Steven D'Aprano wrote: >> >> So what is this unspeakable, nightmarish, cryptic abomination going to look >> like? Here's an example from PEP 484: >> >> def greeting(name: str) -> str: >> return 'Hello ' + name >> >> >> I

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Gregory Ewing
Steven D'Aprano wrote: I'm arguing with those who insist that objects of type MethodType aren't methods, and objects of type FunctionType aren't functions but methods, except when they are, based on that simplified, incomplete glossary entry. I'm not arguing that based on the glossary entry. I

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Gregory Ewing
Steven D'Aprano wrote: Er, perhaps "code injection" is not the best name for this, on account of it also being the name for a security vulnerability anti-pattern: I'm talking about a variety of dependency injection where you either add an entirely new method to an instance, or give the instan

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Gregory Ewing
Steven D'Aprano wrote: Gregory Ewing wrote: If things worked the way you want, it would be impossible to store a function in an instance attribute and get it out again *without* it being treated as a method > Not impossible, just inconvenient... the solution is to use a custom descriptor Bu

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Rick Johnson
On Tuesday, February 3, 2015 at 4:05:57 PM UTC-6, Ian wrote: > On Tue, Feb 3, 2015 at 10:40 AM, Steven D'Aprano wrote: > > AT LONG LAST THE LIGHT DAWNS! THE PENNY DROPS! > > Careful there, you're starting to sound like Ranting Rick. ;-) Ha! My meme's are far more catchy and intellectual. But as t

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Steven D'Aprano
Gregory Ewing wrote: > Marko Rauhamaa wrote: >> Right now Python generates the trampoline from the class prototype every >> time you call a method. If the semantics allowed, you could create the >> trampoline at instantiation time (for better or worse). That way, the >> problem you seem to be refe

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Steven D'Aprano
Gregory Ewing wrote: > Marko Rauhamaa wrote: >> For (almost) all practical purposes, that is the Python way as well. If >> object instantiation (conceptually) copied the class's methods into the >> object's dict, you'd get the semantics I'm looking for. > > If things worked the way you want, it w

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Ethan Furman
On 02/03/2015 03:32 PM, Marko Rauhamaa wrote: > Gregory Ewing : > >> You seem to be suggesting an optimisation that pre-creates bound >> methods when the instance is created. Keeping a cache of bound methods >> would achieve the same thing without changing the semantics. I think >> CPython might a

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Mark Lawrence
On 03/02/2015 23:32, Marko Rauhamaa wrote: Gregory Ewing : You seem to be suggesting an optimisation that pre-creates bound methods when the instance is created. Keeping a cache of bound methods would achieve the same thing without changing the semantics. I think CPython might already be doing

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Chris Angelico
On Wed, Feb 4, 2015 at 10:32 AM, Marko Rauhamaa wrote: > No, I'm saying Python should behave differently. > > Python: > >>>> class A: >...def f(self): >... print("f") >...def g(self): >... print("g") >... >>>> a = A() >>>> a.__class__.f = a.__cla

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Marko Rauhamaa
Gregory Ewing : > You seem to be suggesting an optimisation that pre-creates bound > methods when the instance is created. Keeping a cache of bound methods > would achieve the same thing without changing the semantics. I think > CPython might already be doing that, but I'm not sure. No, I'm sayin

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Gregory Ewing
Marko Rauhamaa wrote: Right now Python generates the trampoline from the class prototype every time you call a method. If the semantics allowed, you could create the trampoline at instantiation time (for better or worse). That way, the problem you seem to be referring to wouldn't materialize. S

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Chris Angelico
On Wed, Feb 4, 2015 at 4:40 AM, Steven D'Aprano wrote: > given that the glossary need not be 100% complete and definitive, "function > defined inside a class body" is close enough to the truth. * This * We are arguing, not about an element in a formal grammar, but about a glossary entry. If one

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Ian Kelly
On Tue, Feb 3, 2015 at 10:40 AM, Steven D'Aprano wrote: > AT LONG LAST THE LIGHT DAWNS! THE PENNY DROPS! Careful there, you're starting to sound like Ranting Rick. ;-) -- https://mail.python.org/mailman/listinfo/python-list

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Gregory Ewing
Steven D'Aprano wrote: If some methods can be defined outside of the body of a class, then being defined inside the body of a class does not define a method. Nobody's disputing that. The business about super() is just a possible reason for the glossary to define the word 'method' in a more rest

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Marko Rauhamaa
Gregory Ewing : > Marko Rauhamaa wrote: >> For (almost) all practical purposes, that is the Python way as well. If >> object instantiation (conceptually) copied the class's methods into the >> object's dict, you'd get the semantics I'm looking for. > > If things worked the way you want, it would b

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Gregory Ewing
Marko Rauhamaa wrote: For (almost) all practical purposes, that is the Python way as well. If object instantiation (conceptually) copied the class's methods into the object's dict, you'd get the semantics I'm looking for. If things worked the way you want, it would be impossible to store a func

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Steven D'Aprano
Devin Jeanpierre wrote: > On Mon, Feb 2, 2015 at 6:07 AM, Steven D'Aprano > wrote: >> Run this code: >> >> # === cut === >> >> class K(object): >> def f(self): pass >> >> def f(self): pass >> >> instance = K() >> things = [instance.f, f.__get__(instance, K)] >> from random import shuffle >> s

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Gregory Ewing
Steven D'Aprano wrote: In Python 2, they are methods. In Python 3, they are functions, and aren't converted into methods until you access them via the instance: They're methods in both cases. They don't have to be "converted into methods"; they already are, by virtue of their location and inte

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Gregory Ewing
Steven D'Aprano wrote: Both K.f and K.g are methods, even though only one meets the definition given in the glossary. The glossary is wrong. Or rather, it is not so much that it is *wrong*, but that it is incomplete and over-simplified. I agree with that; a more complete definition would be "a

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Marko Rauhamaa
Chris Angelico : > On Tue, Feb 3, 2015 at 9:38 PM, Marko Rauhamaa wrote: >> It's slightly sad that Python exposes the two-level attribute lookup. >> It would be more elegant if, conceptually, all methods were retrieved >> from the object's attribute dict. That way, the class would be simply >> a

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Chris Angelico
On Tue, Feb 3, 2015 at 9:38 PM, Marko Rauhamaa wrote: > It's slightly sad that Python exposes the two-level attribute lookup. It > would be more elegant if, conceptually, all methods were retrieved from > the object's attribute dict. That way, the class would be simply a > mundane optimization tri

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Marko Rauhamaa
Devin Jeanpierre : > It isn't mystical. There are differences in semantics of defining > methods inside or outside of a class that apply in certain situations > (e.g. super(), metaclasses). You have cherrypicked an example that > avoids them. It's slightly sad that Python exposes the two-level at

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Devin Jeanpierre
On Mon, Feb 2, 2015 at 6:20 AM, Steven D'Aprano wrote: > Devin Jeanpierre wrote: >> Oops, I just realized why such a claim might be made: the >> documentation probably wants to be able to say that any method can use >> super(). So that's why it claims that it isn't a method unless it's >> defined

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Devin Jeanpierre
On Mon, Feb 2, 2015 at 6:07 AM, Steven D'Aprano wrote: > Run this code: > > # === cut === > > class K(object): > def f(self): pass > > def f(self): pass > > instance = K() > things = [instance.f, f.__get__(instance, K)] > from random import shuffle > shuffle(things) > print(things) > > # === c

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-02 Thread Steven D'Aprano
Devin Jeanpierre wrote: > Oops, I just realized why such a claim might be made: the > documentation probably wants to be able to say that any method can use > super(). So that's why it claims that it isn't a method unless it's > defined inside a class body. You can use super anywhere, including

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-02 Thread Steven D'Aprano
Devin Jeanpierre wrote: > On Mon, Feb 2, 2015 at 4:06 AM, Steven D'Aprano > wrote: >> instance.f is a method by the glossary definition. Its type is identical >> to types.MethodType, which is what I used to create a method by hand. > > You are assuming that they are both methods, just because t

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-02 Thread Devin Jeanpierre
On Mon, Feb 2, 2015 at 5:00 AM, Devin Jeanpierre wrote: > On Mon, Feb 2, 2015 at 4:06 AM, Steven D'Aprano > wrote: >>> On Sun, Feb 1, 2015 at 11:15 PM, Steven D'Aprano >>> wrote: >> Both K.f and K.g are methods, even though only one meets the definition >> given in the glossary. The glossary is

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-02 Thread Devin Jeanpierre
On Mon, Feb 2, 2015 at 4:06 AM, Steven D'Aprano wrote: >> On Sun, Feb 1, 2015 at 11:15 PM, Steven D'Aprano >> wrote: > Both K.f and K.g are methods, even though only one meets the definition > given in the glossary. The glossary is wrong. I agree, it oversimplified and has made a useless distinc

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-02 Thread Steven D'Aprano
Rustom Mody wrote: > My point was more methodological/sociological than technical: > > Are these dunder methods as 'internal' as say the register-allocation used > by a C compiler? Dunder methods are implementation, not interface. If you are the class author, then you care about the implementat

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-02 Thread Rustom Mody
On Monday, February 2, 2015 at 10:57:27 AM UTC+5:30, Vito De Tullio wrote: > Steven D'Aprano wrote: > > > Checking the REPL first would have revealed that [].__dir__ raises > > AttributeError. In other words, lists don't have a __dir__ method. > > ? > > Python 3.4.2 (default, Nov 29 2014, 00:45:

Re: Python is DOOMED! Again!

2015-02-02 Thread Rustom Mody
On Monday, February 2, 2015 at 1:13:30 PM UTC+5:30, Paul Rubin wrote: > Steven D'Aprano writes: > > No apples and no oranges aren't the same thing, but if somebody is > > expecting > > no apples, and I give them no oranges instead, it would be churlish for > > them > > to complain that none of

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-02 Thread Steven D'Aprano
Steven D'Aprano wrote: > Both K.f and K.g are methods, even though only one meets the definition > given in the glossary. The glossary is wrong. Oh I'm sure somebody is going to pick me up on this... In Python 2, they are methods. In Python 3, they are functions, and aren't converted into metho

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-02 Thread Steven D'Aprano
Devin Jeanpierre wrote: > -- Devin > > On Sun, Feb 1, 2015 at 11:15 PM, Steven D'Aprano > wrote: >> Gregory Ewing wrote: >> >>> Steven D'Aprano wrote: [quote] If the object has a method named __dir__(), this method will be called and must return the list of attributes.

Re: Python is DOOMED! Again!

2015-02-01 Thread Paul Rubin
Steven D'Aprano writes: > No apples and no oranges aren't the same thing, but if somebody is expecting > no apples, and I give them no oranges instead, it would be churlish for them > to complain that none of them are the wrong kind of fruit. https://davedevine.wordpress.com/2011/01/20/the-sart

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-01 Thread Devin Jeanpierre
-- Devin On Sun, Feb 1, 2015 at 11:15 PM, Steven D'Aprano wrote: > Gregory Ewing wrote: > >> Steven D'Aprano wrote: >>> [quote] >>> If the object has a method named __dir__(), this method will >>> be called and must return the list of attributes. >>> [end quote] >>> >>> The first

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-01 Thread Steven D'Aprano
Gregory Ewing wrote: > Steven D'Aprano wrote: >> [quote] >> If the object has a method named __dir__(), this method will >> be called and must return the list of attributes. >> [end quote] >> >> The first inaccuracy is that like all (nearly all?) dunder methods, >> Python only loo

Re: Python is DOOMED! Again!

2015-02-01 Thread Steven D'Aprano
Paul Rubin wrote: > Chris Angelico writes: >> So since you can set something to Nothing regardless of type, and >> compare it against Nothing regardless of type, it doesn't really much >> matter that there are different types of Nothing. Right? > > No that's not how type inference works. If you

Re: Python is DOOMED! Again!

2015-02-01 Thread Paul Rubin
Chris Angelico writes: > If you say "x = 5" and pass it to a function that accepts "Int or > String", the compiler knows that it's actually an Int. If you then > also pass that x to something that takes "Int or List", is that legal? You'd have to do that with type classes, but yeah, the compiler

Re: Python is DOOMED! Again!

2015-02-01 Thread Chris Angelico
On Mon, Feb 2, 2015 at 5:07 PM, Paul Rubin wrote: > Chris Angelico writes: >> So since you can set something to Nothing regardless of type, and >> compare it against Nothing regardless of type, it doesn't really much >> matter that there are different types of Nothing. Right? > > No that's not ho

Re: Python is DOOMED! Again!

2015-02-01 Thread Paul Rubin
Steven D'Aprano writes: > if type(ptr) == A: > if ptr != Anil: ... > if type(ptr) == B: > if ptr != Bnil: ... > etc. That would be insane. So how does Haskell do this? That wouldn't make sense in Haskell: the types are known at compile time, so you wouldn't do that runtime switching on t

Re: Python is DOOMED! Again!

2015-02-01 Thread Paul Rubin
Chris Angelico writes: > So since you can set something to Nothing regardless of type, and > compare it against Nothing regardless of type, it doesn't really much > matter that there are different types of Nothing. Right? No that's not how type inference works. If you have x = Nothing and pass i

Re: Python is DOOMED! Again!

2015-02-01 Thread Gregory Ewing
Devin Jeanpierre wrote: I answered my own question later, by accident: Java nulls are castable to each other if you do it explicitly (routing through Object -- e.g. (Something)((Object) ((SomeOtherThing) null. So in that sense, there is only one null, just with some arbitrary compiler distin

Re: Python is DOOMED! Again!

2015-02-01 Thread Chris Angelico
On Mon, Feb 2, 2015 at 4:19 PM, Gregory Ewing wrote: > In Haskell you would just go ahead and compare ptr > with Nothing (or more likely pattern-match it against > Nothing). So since you can set something to Nothing regardless of type, and compare it against Nothing regardless of type, it doesn't

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-01 Thread Vito De Tullio
Steven D'Aprano wrote: > Checking the REPL first would have revealed that [].__dir__ raises > AttributeError. In other words, lists don't have a __dir__ method. ? Python 3.4.2 (default, Nov 29 2014, 00:45:45) [GCC 4.8.3] on linux Type "help", "copyright", "credits" or "license" for more informa

Re: Python is DOOMED! Again!

2015-02-01 Thread Gregory Ewing
Steven D'Aprano wrote: If I have an arbitrary pointer, and I want to check if it is safe to dereference, how do I do it? Surely I'm not expected to write something like: if type(ptr) == A: if ptr != Anil: ... if type(ptr) == B: if ptr != Bnil: ... etc. That would be insane. So how doe

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-01 Thread Gregory Ewing
Steven D'Aprano wrote: [quote] If the object has a method named __dir__(), this method will be called and must return the list of attributes. [end quote] The first inaccuracy is that like all (nearly all?) dunder methods, Python only looks for __dir__ on the class, not the inst

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-01 Thread Rustom Mody
On Monday, February 2, 2015 at 9:34:53 AM UTC+5:30, Rustom Mody wrote: > On Monday, February 2, 2015 at 9:22:51 AM UTC+5:30, Rustom Mody wrote: > > On Sunday, February 1, 2015 at 9:51:11 PM UTC+5:30, Steven D'Aprano wrote: > > > Rustom Mody wrote: > > > > > > > The other day I was taking a class i

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-01 Thread Rustom Mody
On Monday, February 2, 2015 at 9:22:51 AM UTC+5:30, Rustom Mody wrote: > On Sunday, February 1, 2015 at 9:51:11 PM UTC+5:30, Steven D'Aprano wrote: > > Rustom Mody wrote: > > > > > The other day I was taking a class in which I was showing > > > - introspection for discovering -- help, type, dir et

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-01 Thread Rustom Mody
On Sunday, February 1, 2015 at 9:51:11 PM UTC+5:30, Steven D'Aprano wrote: > Rustom Mody wrote: > > > The other day I was taking a class in which I was showing > > - introspection for discovering -- help, type, dir etc at the repl > > - mapping of surface syntax to internals eg. a + b ←→ a.__add__

Re: Python is DOOMED! Again!

2015-02-01 Thread Steven D'Aprano
Devin Jeanpierre wrote: > So in that sense, there is only one null, just with some arbitrary > compiler distinctions you can break through if you try hard enough. Woo hoo! I was right! *Dances the Dance of Victory!* -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python is DOOMED! Again!

2015-02-01 Thread Devin Jeanpierre
On Sun, Feb 1, 2015 at 2:27 PM, Paul Rubin wrote: > Devin Jeanpierre writes: >> That said, Haskell (and the rest) do have a sort of type coercion, of >> literals at compile time (e.g. 3 can be an Integer or a Double >> depending on how you use it.) > > That's polymorphism, not coercion. OK, yes,

Re: Python is DOOMED! Again!

2015-02-01 Thread Paul Rubin
Devin Jeanpierre writes: > That said, Haskell (and the rest) do have a sort of type coercion, of > literals at compile time (e.g. 3 can be an Integer or a Double > depending on how you use it.) That's polymorphism, not coercion. The compiler figures out at compile time what type of 3 you actuall

Re: Python is DOOMED! Again!

2015-02-01 Thread Paul Rubin
Steven D'Aprano writes: > C has a single nil pointer compatible with all pointer types. C++11 has a separate type just for the null pointer, which can be automatically coerced to other pointer types. I'm not sure but I think that means it is couthing up slightly. http://en.cppreference.com/w/cp

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-01 Thread Emile van Sebille
On 2/1/2015 12:45 PM, Chris Angelico wrote: Simple answer: You write dunder methods and the interpreter calls them. You don't call them yourself. I can't currently think of any situation where it's appropriate to call a dunder method manually (cue the swamping of such situations on the list); yo

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-01 Thread Chris Angelico
On Sun, Feb 1, 2015 at 4:36 PM, Rustom Mody wrote: > The other day I was taking a class in which I was showing > - introspection for discovering -- help, type, dir etc at the repl > - mapping of surface syntax to internals eg. a + b ←→ a.__add__(b) > > And a student asked me the diff between > dir

Re: Python is DOOMED! Again!

2015-02-01 Thread Devin Jeanpierre
On Sun, Feb 1, 2015 at 8:31 AM, Steven D'Aprano wrote: > Paul Rubin wrote: >> It's completely practical: polymorphism and type inference get you the >> value you want with usually no effort on your part. > > But it's the "usually" that bites you. > > If I have an arbitrary pointer, and I want to c

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-01 Thread Ian Kelly
On Sun, Feb 1, 2015 at 9:55 AM, Steven D'Aprano wrote: > Steven D'Aprano wrote: > >> len tries to call __len__ if it exists, and if not, it tries walking the >> iterable counting items. > > Hmmm, I may have mis-remembered that. Perhaps I'm thinking of Ruby. I think you just got it backward. iter

Re: Python is DOOMED! Again!

2015-02-01 Thread Steven D'Aprano
Steven D'Aprano wrote: > Devin Jeanpierre wrote: > >> It's really only dynamically typed languages that have a single null >> value of a single type. Maybe I misunderstand the original statement. > > Pascal is statically typed and has a single null pointer compatible with > all pointer types.

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-01 Thread Steven D'Aprano
Steven D'Aprano wrote: > len tries to call __len__ if it exists, and if not, it tries walking the > iterable counting items. Hmmm, I may have mis-remembered that. Perhaps I'm thinking of Ruby. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python is DOOMED! Again!

2015-02-01 Thread Devin Jeanpierre
On Sun, Feb 1, 2015 at 8:34 AM, Steven D'Aprano wrote: > Devin Jeanpierre wrote: > >> It's really only dynamically typed languages that have a single null >> value of a single type. Maybe I misunderstand the original statement. > > Pascal is statically typed and has a single null pointer compatibl

Re: Python is DOOMED! Again!

2015-02-01 Thread Steven D'Aprano
Devin Jeanpierre wrote: > It's really only dynamically typed languages that have a single null > value of a single type. Maybe I misunderstand the original statement. Pascal is statically typed and has a single null pointer compatible with all pointer types. C has a single nil pointer compatible

Re: Python is DOOMED! Again!

2015-02-01 Thread Steven D'Aprano
Paul Rubin wrote: > Steven D'Aprano writes: >> Some degree of weakness in a type system is not necessarily bad. Even the >> strongest of languages usually allow a few exceptions, such as numeric >> coercions. > > Haskell doesn't have automatic coercions of any sort. You have to call > a convers

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-01 Thread Steven D'Aprano
Rustom Mody wrote: > The other day I was taking a class in which I was showing > - introspection for discovering -- help, type, dir etc at the repl > - mapping of surface syntax to internals eg. a + b ←→ a.__add__(b) > > And a student asked me the diff between > dir([]) > and > [].__dir__() > >

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-01 Thread Ethan Furman
On 01/31/2015 09:36 PM, Rustom Mody wrote: > > And a student asked me the diff between > dir([]) > and > [].__dir__() > > I didnt know what to say... > Now surely the amount of python I dont know is significantly larger than what > I know > Still it would be nice to have surface-syntax ←→ dunder

Re: Python is DOOMED! Again!

2015-01-31 Thread Devin Jeanpierre
Sorry, sort of responding to both of you. On Sat, Jan 31, 2015 at 10:12 PM, Paul Rubin wrote: > Steven D'Aprano writes: >> Some degree of weakness in a type system is not necessarily bad. Even the >> strongest of languages usually allow a few exceptions, such as numeric >> coercions. > > Haskell

Re: Python is DOOMED! Again!

2015-01-31 Thread Paul Rubin
Steven D'Aprano writes: > Some degree of weakness in a type system is not necessarily bad. Even the > strongest of languages usually allow a few exceptions, such as numeric > coercions. Haskell doesn't have automatic coercions of any sort. You have to call a conversion function if you want to tu

dunder-docs (was Python is DOOMED! Again!)

2015-01-31 Thread Rustom Mody
On Sunday, February 1, 2015 at 10:15:13 AM UTC+5:30, Ethan Furman wrote: > On 01/31/2015 07:16 PM, Steven D'Aprano wrote: > > > > But by default, Python will fallback on __repr__ if __str__ doesn't exist, > > or __str__ if __repr__ doesn't exist, or both. Or something. (I always > > forget what th

Re: Python is DOOMED! Again!

2015-01-31 Thread Ethan Furman
On 01/31/2015 07:16 PM, Steven D'Aprano wrote: > > But by default, Python will fallback on __repr__ if __str__ doesn't exist, > or __str__ if __repr__ doesn't exist, or both. Or something. (I always > forget what the rules are exactly.) If __str__ is missing, __repr__ is called. If __repr__ is m

Re: Python is DOOMED! Again!

2015-01-31 Thread Chris Angelico
On Sun, Feb 1, 2015 at 2:16 PM, Steven D'Aprano wrote: > Chris Angelico wrote: > >> On Sat, Jan 31, 2015 at 10:56 PM, Steven D'Aprano >> wrote: >>> Both ints and floats are models of the same abstract thing, namely >>> "number". Ideally, from a mathematically standpoint, there should be no >>> di

Re: Python is DOOMED! Again!

2015-01-31 Thread Steven D'Aprano
Chris Angelico wrote: > On Sat, Jan 31, 2015 at 10:56 PM, Steven D'Aprano > wrote: >> Both ints and floats are models of the same abstract thing, namely >> "number". Ideally, from a mathematically standpoint, there should be no >> difference between 23 and 23.0. Automatic coercions allow us to ge

Re: Python is DOOMED! Again!

2015-01-31 Thread Steven D'Aprano
Mario Figueiredo wrote: > In article <54ca5bbf$0$12992$c3e8da3$54964...@news.astraweb.com>, > steve+comp.lang.pyt...@pearwood.info says... >> >> Why should I feel guilty? You wrote: >> >> >> "Static analysis cannot and should not clutter executable code." >> >> >> But what are type declaratio

Re: Python is DOOMED! Again!

2015-01-31 Thread Chris Angelico
On Sat, Jan 31, 2015 at 10:56 PM, Steven D'Aprano wrote: > Both ints and floats are models of the same abstract thing, namely "number". > Ideally, from a mathematically standpoint, there should be no difference > between 23 and 23.0. Automatic coercions allow us to get a little closer to > that id

Re: Python is DOOMED! Again!

2015-01-31 Thread Steven D'Aprano
random...@fastmail.us wrote: > On Thu, Jan 29, 2015, at 10:56, Steven D'Aprano wrote: >> Bar language, on the other hand, tries extremely hard to ensure that >> every >> type is automatically able to be coerced into every other type. The >> coercion might not do what you expect, but it will do *so

Re: Python is DOOMED! Again!

2015-01-30 Thread Ian Kelly
On Fri, Jan 30, 2015 at 11:42 AM, Mario Figueiredo wrote: > To be clear, type declarations in Julia, Scala, C have the potential to > produce side-effects, can result in optimized code and can result in > compile time errors or warnings. They also affect runtime evaluation as > you could easily at

Re: Python is DOOMED! Again!

2015-01-30 Thread Skip Montanaro
On Fri, Jan 30, 2015 at 12:50 PM, Mario Figueiredo wrote: > It would help that if instead of weakly typed or strongly typed box, > they could be classified comparatively to each other. The terms are > better suited to describe two languages as they stand to each other. > > Weakly Typed --

Re: Python is DOOMED! Again!

2015-01-30 Thread Mario Figueiredo
In article , breamore...@yahoo.co.uk says... > > No, they're not always weakly typed. The aim of the spreadsheet put up > by Skip was to sort out (roughly) which languages belong in which camp. > I do not regard myself as suitably qualified to fill the thing out. > Perhaps by now others hav

Re: Python is DOOMED! Again!

2015-01-30 Thread Mario Figueiredo
In article <54ca5bbf$0$12992$c3e8da3$54964...@news.astraweb.com>, steve+comp.lang.pyt...@pearwood.info says... > > > Why should I feel guilty? You wrote: > > > "Static analysis cannot and should not clutter executable code." > > > But what are type declarations in statically typed languages

Re: Python is DOOMED! Again!

2015-01-30 Thread Mario Figueiredo
In article <54ca5bbf$0$12992$c3e8da3$54964...@news.astraweb.com>, steve+comp.lang.pyt...@pearwood.info says... > > Why should I feel guilty? You wrote: > > > "Static analysis cannot and should not clutter executable code." > > > But what are type declarations in statically typed languages lik

Re: Python is DOOMED! Again!

2015-01-29 Thread MRAB
On 2015-01-29 23:25, Chris Kaynor wrote: On Thu, Jan 29, 2015 at 2:57 PM, BartC wrote: [snip] Putting in hints, (as as I implemented them using primitive types), meant that functions and code no longer worked in a generic (or polymorphic) manner. Code also changes, but the type hints aren't ma

Re: Python is DOOMED! Again!

2015-01-29 Thread Chris Kaynor
On Thu, Jan 29, 2015 at 2:57 PM, BartC wrote: > I've read most of the thread but haven't been able to figure out /why/ this > is being proposed. What is the advantage, speed? Check out the rationale part of the PEP: https://www.python.org/dev/peps/pep-0484/#rationale-and-goals. Other parts of the

Re: Python is DOOMED! Again!

2015-01-29 Thread Chris Angelico
On Fri, Jan 30, 2015 at 9:57 AM, BartC wrote: > I've read most of the thread but haven't been able to figure out /why/ this > is being proposed. What is the advantage, speed? Have a read of the PEP: https://www.python.org/dev/peps/pep-0484/ ChrisA -- https://mail.python.org/mailman/listinfo/py

Re: Python is DOOMED! Again!

2015-01-29 Thread BartC
On 22/01/2015 04:30, Steven D'Aprano wrote: https://www.python.org/dev/peps/pep-0484/ Here's a potential real-world example, from the statistics module in Python 3.4, before and after adding annotations: def median_grouped(data, interval=1): ... def median_grouped(data:Iterable[Real], inter

Re: Python is DOOMED! Again!

2015-01-29 Thread Rick Johnson
On Thursday, January 29, 2015 at 10:11:56 AM UTC-6, Steven D'Aprano wrote: > > But what are type declarations in statically typed > languages like C, Pascal, Haskell, etc.? They are used by > the compiler for static analysis. The same applies to type > declarations in dynamically typed languages li

Re: Python is DOOMED! Again!

2015-01-29 Thread Mark Lawrence
On 29/01/2015 18:23, random...@fastmail.us wrote: Statically typed lanugages by definition can never give you a TypeError - there are no runtime conversions that can succeed or fail based on the type of the arguments. What makes a statically typed language strong or weak? Are statically typed la

Re: Python is DOOMED! Again!

2015-01-29 Thread random832
On Thu, Jan 29, 2015, at 10:56, Steven D'Aprano wrote: > Bar language, on the other hand, tries extremely hard to ensure that > every > type is automatically able to be coerced into every other type. The > coercion might not do what you expect, but it will do *something*: See, this is where the co

Re: Python is DOOMED! Again!

2015-01-29 Thread Steven D'Aprano
Mario Figueiredo wrote: > In article <54c980cd$0$12981$c3e8da3$54964...@news.astraweb.com>, > steve+comp.lang.pyt...@pearwood.info says... >> >> Ian, that's obvious. Just open your eyes: >> >> Scala >> def addInt( a:Int, b:Int ) : Int >> >> Python >> def addInt( a:int, b:int ) -> int: >> >> >

Re: Python is DOOMED! Again!

2015-01-29 Thread Ian Kelly
On Thu, Jan 29, 2015 at 1:34 AM, Mario Figueiredo wrote: > In article <54c980cd$0$12981$c3e8da3$54964...@news.astraweb.com>, > steve+comp.lang.pyt...@pearwood.info says... >> >> Ian, that's obvious. Just open your eyes: >> >> Scala >> def addInt( a:Int, b:Int ) : Int >> >> Python >> def addInt( a:

Re: Python is DOOMED! Again!

2015-01-29 Thread Steven D'Aprano
Mario Figueiredo wrote: > In article , > breamore...@yahoo.co.uk says... >> >> C and C++ are weakly and statically typed languages. Python is a >> strongly and dynamically typed language. Therefore anything following >> based on the above paragraph alone is wrong. >> > > Indeed. I confused st

Re: Python is DOOMED! Again!

2015-01-29 Thread Steven D'Aprano
random...@fastmail.us wrote: > On Wed, Jan 28, 2015, at 13:16, Mark Lawrence wrote: >> C and C++ are weakly and statically typed languages. > > "strong typing" has no meaning at all, and "weak typing" means "anything > I don't like". I see you've been reading Chris Smith's essay on typing :-) h

Re: Python is DOOMED! Again!

2015-01-29 Thread random832
On Wed, Jan 28, 2015, at 13:16, Mark Lawrence wrote: > C and C++ are weakly and statically typed languages. "strong typing" has no meaning at all, and "weak typing" means "anything I don't like". The fact that you can add an int and a float, or that you can use any object as a boolean, would make

Re: Python is DOOMED! Again!

2015-01-29 Thread Mark Lawrence
On 29/01/2015 08:23, Mario Figueiredo wrote: In article , breamore...@yahoo.co.uk says... C and C++ are weakly and statically typed languages. Python is a strongly and dynamically typed language. Therefore anything following based on the above paragraph alone is wrong. Indeed. I confused s

Re: Python is DOOMED! Again!

2015-01-29 Thread Mario Figueiredo
In article <54c980cd$0$12981$c3e8da3$54964...@news.astraweb.com>, steve+comp.lang.pyt...@pearwood.info says... > > Ian, that's obvious. Just open your eyes: > > Scala > def addInt( a:Int, b:Int ) : Int > > Python > def addInt( a:int, b:int ) -> int: > > > They're COMPLETELY different. In Scal

Re: Python is DOOMED! Again!

2015-01-29 Thread Mario Figueiredo
In article , breamore...@yahoo.co.uk says... > > C and C++ are weakly and statically typed languages. Python is a > strongly and dynamically typed language. Therefore anything following > based on the above paragraph alone is wrong. > Indeed. I confused strongly/weakly with static. I feel a

Re: Python is DOOMED! Again!

2015-01-28 Thread Chris Angelico
On Thu, Jan 29, 2015 at 11:37 AM, Steven D'Aprano wrote: > They're as > different as cheese and a very slightly different cheese. Do try to keep > up. As different as brie and camembert? ChrisA -- https://mail.python.org/mailman/listinfo/python-list

  1   2   3   >