Applications Google
Menu principal

Post a Comment On: Only Python

""where" keyword and Python as pseudo-code"

10 Comments -

1 – 10 of 10
Blogger André Roberge said...

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.

9:48 PM

Anonymous Anonymous said...

A fabulous idea. I really like it!

1:34 AM

Anonymous Anonymous said...

It's a great idea ..
it's the way to go !!
it has an optionnal form, and a powerful feature !
it's pythonic !
it's THE way !

7:07 AM

Anonymous Anonymous said...

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?

7:34 AM

Blogger André Roberge said...

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.

7:42 AM

Anonymous Anonymous said...

Yes for the idea, but:

- you show only a way to specify signature variables.
All other locals seems not to be cared of.
Or perhaps,I assume you want to declare them all in your where stuff (!!)

- I can't see the interet of your anonymous functions.
What's the advantage of your example compared to
def powers(x):return x*x

mylist=[powers(x) for x....]

- for the sub-class, I'd rather mix classes and interfaces :
class C(C1,C2,I)
Since interface are already declared with a special statement, no need to differentiate them *again*


--OPQ

11:57 AM

Blogger Edward Robertson said...

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.:

def gcd(a, b):
where:
a: int, b: int
gcd -> int

I realize that the arrow syntax would be new, but Guido used it in his writings on optional static typing.

12:32 PM

Anonymous Anonymous said...

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.

12:32 PM

Blogger André Roberge said...

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:

return ((x, y, z), state, colour, fname) where:
x: float, y: float, z: float # final position
state: int # moving or at rest
colour: type(Colour) # user-defined
fname: str # temporary filename used to store data

(note: spacing information might be lost by blogger.com in above code.)

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.

1:29 PM

Anonymous Anonymous said...

I was just thinking how cool it'd be to have a keyword like this. Great minds...

1:44 AM

Spammers: none shall pass.
You can use some HTML tags, such as <b>, <i>, <a>

Comments on this blog are restricted to team members.

You will be asked to sign in after submitting your comment.
Please prove you're not a robot