tag:blogger.com,1999:blog-9266717.post110513624626431553..comments2023-05-22T10:01:23.167-03:00Comments on Only Python: "where" keyword and Python as pseudo-codeAndré Robergehttp://www.blogger.com/profile/08131391818998844540noreply@blogger.comBlogger10125tag:blogger.com,1999:blog-9266717.post-47245374510956928782009-01-31T01:44:00.000-04:002009-01-31T01:44:00.000-04:00I was just thinking how cool it'd be to have a key...I was just thinking how cool it'd be to have a keyword like this. Great minds...Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-9266717.post-1105378190310192562005-01-10T13:29:00.000-04:002005-01-10T13:29:00.000-04:00Regarding the comment about using gcd -> int to sp...Regarding the comment about using gcd -> int to specify return value. Suppose I have a function that returns multiple parameters; I might want to be able to eventually do something like the following:<br /><br />return ((x, y, z), state, colour, fname) where:<br /> x: float, y: float, z: float # final position<br /> state: int # moving or at rest<br /> colour: type(Colour) # user-defined<br /> fname: str # temporary filename used to store data <br /><br />(note: spacing information might be lost by blogger.com in above code.)<br /><br />i.e. add additional information as required. Furthermore, in my opinion, the notation for type information should be the same whether it is for input or output.André Robergehttps://www.blogger.com/profile/08131391818998844540noreply@blogger.comtag:blogger.com,1999:blog-9266717.post-1105374759020340292005-01-10T12:32:00.001-04:002005-01-10T12:32:00.001-04:00Case 1 looks a lot like a transcript of what Psyco...Case 1 looks a lot like a transcript of what Psyco does behind the scenes. I'd also expect the transcript of a mythical type inference mechanism to look pretty similar. It's therefore quite a convenient notation, but possibly unnecessary as a language construct given a decent enough compiler infrastructure.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-9266717.post-1105374754051026392005-01-10T12:32:00.000-04:002005-01-10T12:32:00.000-04:00Rather than have to specify a new name "c" when yo...Rather than have to specify a new name "c" when you want to describe the return type, what about using the arrow notation? e.g.:<br /><br />def gcd(a, b):<br /> where:<br /> a: int, b: int<br /> gcd -> int<br /><br />I realize that the arrow syntax would be new, but Guido used it in his writings on optional static typing.Edward Robertsonhttps://www.blogger.com/profile/15358398357596932277noreply@blogger.comtag:blogger.com,1999:blog-9266717.post-1105372642706219682005-01-10T11:57:00.000-04:002005-01-10T11:57:00.000-04:00Yes for the idea, but:
- you show only a way to s...Yes for the idea, but:<br /><br />- you show only a way to specify signature variables.<br />All other locals seems not to be cared of.<br />Or perhaps,I assume you want to declare them all in your where stuff (!!)<br /><br />- I can't see the interet of your anonymous functions.<br />What's the advantage of your example compared to<br />def powers(x):return x*x<br /><br />mylist=[powers(x) for x....]<br /><br />- for the sub-class, I'd rather mix classes and interfaces :<br />class C(C1,C2,I)<br />Since interface are already declared with a special statement, no need to differentiate them *again*<br /><br /><br />--OPQAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-9266717.post-1105357331288514532005-01-10T07:42:00.000-04:002005-01-10T07:42:00.000-04:00Of course, one could have pre- and post- condition...Of course, one could have pre- and post- conditions without *optional* static typing. While I did not show any example of this in this post (nor on the following post) it is clearly allowed by this syntax.André Robergehttps://www.blogger.com/profile/08131391818998844540noreply@blogger.comtag:blogger.com,1999:blog-9266717.post-1105356846208425152005-01-10T07:34:00.000-04:002005-01-10T07:34:00.000-04:00I like it a lot. It lumps object type with other ...I like it a lot. It lumps object type with other pre-conditions which makes it more flexible and empahsizes the "optional" part. I assume that you could specify pre-conditions without specifying type. Is that your intention?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-9266717.post-1105355230425142612005-01-10T07:07:00.000-04:002005-01-10T07:07:00.000-04:00It's a great idea ..
it's the way to go !!
it has ...It's a great idea ..<br />it's the way to go !!<br />it has an optionnal form, and a powerful feature !<br />it's pythonic !<br />it's THE way !Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-9266717.post-1105248887820505452005-01-09T01:34:00.000-04:002005-01-09T01:34:00.000-04:00A fabulous idea. I really like it!A fabulous idea. I really like it!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-9266717.post-1105148928890472032005-01-07T21:48:00.000-04:002005-01-07T21:48:00.000-04:00Please note that Blogger keeps messing up with spa...Please note that Blogger keeps messing up with spacing; I tried to indent using 4 spaces everywhere but, when I "publish" the page, the indention gets messed-up.André Robergehttps://www.blogger.com/profile/08131391818998844540noreply@blogger.com