News for hackers. Stuff that matters.
Re:Unholy: _why's Ruby to Python compiler by regularfry on Monday March 14, 2011 @05:21AM (#2321840)
Python's syntax has some irritating holes in it too. Why, for instance, do class methods rely on annotations? Why not take advantage of the explicit self? It's almost like there's a blessed core to Python's syntax that crystalised in about 2000, and nothing since then has been allowed to infringe on it.
Re:Unholy: _why's Ruby to Python compiler by Ingaz on Monday March 14, 2011 @08:25PM (#2325185)
>> Why, for instance, do class methods rely on annotations?

Python do not have annotations. Decorators are not like java annotations.

>>Why not take advantage of the explicit self?

I think "self" is good. Python lets you bloody patch python objects and classes in runtime and "self" makes it more clear.

Something like:

class MyClass(object): pass

def setX(self,x): self.x = x

MyClass.setX = setX

mc = MyClass()

mc.getX = lambda self: self.x

(INB4: I do not think that bloody patching is good practice)

Re:Unholy: _why's Ruby to Python compiler by regularfry on Tuesday March 15, 2011 @05:13PM (#2329418)
> Python do not have annotations. Decorators are not like java annotations.

Sorry, yes - wrong word. The point stands, though. For class methods to require the use of a feature as outside the core syntax as decorators just screams of a hacked-in afterthought.

> I think "self" is good.

I am indifferent to it, but the fact that the space in the syntax opened up by requiring an explicit receiver on all method definitions is not taken advantage of for class methods speaks volumes.

Re:Unholy: _why's Ruby to Python compiler by Ingaz on Thursday March 17, 2011 @05:40PM (#2338239)
Class methods are not so useful in python as in java and C#.

I think that classmethods was added only for java/C# folks.

In fact it's always better just to combine defs in module and use it as module.method.

I like the approach in Scala with "objects" (Scala-singletones).

About "self": I don't understand you. Can you show me a language with optional (not forced) OOP, that lets you bloody patch objects and classes that deals with this problem in better way?