Functions and receivers func ( r receiver)

(Cherolyn Lexvold) #1

In “func ( r receiver)”
what is “r”? Is it an identifier?
Sorry if my questions sound infantile. I have nowhere else to ask such questions

(Norbert Melzer) #2

In this example, the Abs method has a receiver of type Vertex named v .

To be honest, what should it be otherwise? even receiver is an identifier… At least in the place where you have that word…

(Cherolyn Lexvold) #3

Go does not have classes. I have no idea what that means.

There are so many things on this page that I know nothing about.

even receiver is an identifier Thanks!

But this is the section you’re referring to: the Abs method has a receiver of type Vertex named v .

Thank you. I just have to keep at it and eventually it will become clear

(Cherolyn Lexvold) #4

So this receiver is named r?

(Cherolyn Lexvold) #5

Just working on terminology here

(Norbert Melzer) #6

Yes. But even though its of type receiver, its not necessarily the receiver of a method, as the snippet you have shown is either incomplete (it lacks the actual method name, arguments and return type) or is the type of a function that takes a single argument of type receiver and returns nothing/void

(Cherolyn Lexvold) #7

To be more specific, when Go speaks of an identifier, is this a term that is specific to Go? And/or programming? Or are we to understand “identifier” as the common English definition “a person or thing that identifies something.” In looking for this last, I found, "COMPUTING a sequence of characters used to identify or refer to a program or an element, such as a variable or a set of data, within it.
I must be on the right track.
While possibly seeming elementary, this word has sounded like a foreign language to me, as I consider all the elements of Go until I know their definition specifically.

(Cherolyn Lexvold) #8

This is useful

(Cherolyn Lexvold) #9

More terms that almost, but not quite, mystify me.

Method, I have no clue.

Name, I’ve got down.

Arguments, I’m starting to get, but I don’t have a clear definition.

Return, all I’ve got in my head is that it’s something that returns something…so a bit nebulous.

Type used to really confuse me. Previously type to me was something that you typed, ie with a typewriter (I’m old) or computer keyboard. This definition has been very helpful to me: “a classification of data”

(Lutz Horn) #10

May I point you back to this advice?

I fear that for you Go and this forum are not good choices for starting to learn programming.

A completely different approach could be Scheme and the very good and thorough book How to Design Programs (available online). Please take a look, not to short, at this book. Spend some hours or days trying to understand what it teaches. Perhaps this is an approach that works for you.

(Cherolyn Lexvold) #11

Thank you for your opinion, but I don’t think you are correct

(Gonzalo Chumillas) #12

I understand it as “the target parameter”.