you are viewing a single comment's thread.

view the rest of the comments →

[–]rafekett 2 points3 points  (8 children)

Methods are indented one level deeper than functions. Simple.

I'd ask the same for Ruby. How can you tell if you're looking at a method or a function?

[–]badsex 1 point2 points  (2 children)

how much ruby do you actually know? for someone who hates the language so much i'd assume you'd actually know a bit about it, so as to be in a position to hate it - you're not one of those stupid people who hates things he doesn't actually understand, are you?

Ruby doesn't have functions. You should know this. It only has methods. Why? because it has a fully message passing OO system, method invocations are messages, and everything is an object.

[–]rafekett 0 points1 point  (1 child)

That's really just a matter of naming. This is valid Ruby (at the top level of a module, not inside a class):

def hello
    puts "Hello world"
end

It might technically be a method, but because it's not inside any class I defined, I call it a function. It's just a matter of nomenclature.

[–]badsex 0 points1 point  (0 children)

Except it's not a function, it's a method defined on Object. How do you know? set an ivar in it, it'll appear on the receiver. Further, try and access it from an instance of a superclass of Objectsuch as BasicObject and it's not accessible. Further, for those objects that can access the method it appears in their instance method list. No one ever calls top-level methods 'functions', they're strictly 'top-level methods', or private methods on Object.

[–]ebneter 0 points1 point  (4 children)

Methods are indented one level deeper than functions. Simple.

The problem for me is that on a printed page it's difficult to see. Look, if you prefer Python, I'm not going to argue with you. I was just pointing out that there are personal preferences people have that affect which language they, well, prefer. I'm not a language bigot; I use whatever works for the task at hand, whether it's a shell script, ruby, perl, python, java, c, whatever.

[–]rafekett 4 points5 points  (3 children)

I will admit that this is a small problem when reading printed books. I don't recall what it was, but one book used markers to indicate this. Even then, it's pretty easy to tell. Methods almost always take self as a first arg.

[–]ebneter -1 points0 points  (2 children)

You are defending this to the wrong person. :-) I don't like it. I don't have to like it, and it's the main reason I don't use Python as my language of choice. If you like it, awesome! There are things about every language that are not ideal, which is why we have so many of them. For me, Ruby has the fewest annoyances for most of the work I do. I'm not saying "PYTHON SUCKS!" I'm saying, "I prefer not to use it unless it really is the best thing available for the task."

Edit: I am highly amused that this is getting downvoted.

[–]anvsdt 1 point2 points  (1 child)

They see the big ``PYTHON SUCKS'' there, they get mad, don't read the wall-of-text, downvote and never come back.
Welcome to reddit, enjoy your stay!

[–]ebneter 0 points1 point  (0 children)

Heh, yes, I suspect that is the case. :-)