Syntax error: favFood := "Italian" used as value

cool

https://play.golang.org/p/aYmQM3kAEkx

Interesting

https://golang.org/ref/spec#Iota I can tell I’m going to need to go over this information more than once

It’s late. I’m sure I’ll get it eventually

ConstSpec describes a non terminal of golangs grammar. Just follow the link to get to [it’s definition ](

It’s beginning to make sense

Thank you for your very helpful explanation of iota. I think I’ll save it.

Saved that. What is the difference between declaring and assigning?

Oh it looks like Jayts is answering that. Let me read further.

To declare a variable means to associate an unchangeable type to it. Eg var foo int declares that foo is of type int.

Assigning then puts a value into the variable. foo = 5.

1 Like

Lol. There must be some good reason that you… can use a short variable declaration (with the := operator) only inside of function definitions.

Don’t know what this means. “In other words, variables are “read/write”, while constants are “read only”.”

Oh. Yes not ready for intermediate :neutral_face:

“First, the program is compiled, and then the executable file produced by the compiler is run.”

Intriguing.

com·pile COMPUTING

(of a computer) convert (a program) into a machine-code or lower-level form in which the program can be executed.

(That’s for me.)

In this case, the “commands” are simply program instructions, whose execution is chained together. The term run is used almost synonymously. A related meaning of both "to run " and "to execute " refers to the specific action of a user starting (or launching or invoking) a program, as in “Please run the application.”

[

Execution (computing) - Wikipedia

](https://en.wikipedia.org/wiki/Execution_(computing))

(Also for me)

In computing, a process is an instance of a [computer program that is being executed. It contains the program code and its activity. Depending on the operating system(OS), a process may be made up of multiple [threads of execution]

As you can see, I’m a baby learning to talk

I want so much to read more but I’m out of time. “Lord-willing” I’ll be back tomorrow

Read write (RW or R/W) vs. read-only (RO):

Read/write means that you can retrieve (read) the value, and also change the value. Think of it in terms of your computer’s hard disk. It saves data in files, and you can change the contents of files.

Maybe you’ve encountered some files you cannot change. Those are “read only”. An example are files on CD-ROM (which stands for Compact Disk - Read Only Memory). You can read the CD-ROM, but you cannot change it.

This concept exists at all levels of computing, from low-level technolgies like CD-ROMs and DVD-ROMs and read-only memory (ROM chips). With those technologies, it is physically impossible to change the data.

At higher levels, the nature of the data is determined by software. For example, it’s possible to modify permissions on files to allow or disallow writing. Those permissions are handled by the operating system. In Go, when you create (open) a new file, you can specify whether the file is read-only or read-write. If you want to write to a file, you need the file to be writeable, and you will get errors if you try to write to a file that is read-only.

And in the Go language, consts have a read-only quality because their values cannot change, while vars have a read-write quality. You can set them to a value, and later set them to another value.

About compiling:

A simple way to think of compiling is that it is a way of translating from one language to another. The Go compiler translates from the Go Programming Language to the language that the CPU understands, which is called “machine language”. Here is a nice Wikipedia article on machine code:

I suggest you read that and see how much you can understand. The concepts are fundamental to understanding electronic computers. Go is designed to work closely with the computer’s hardware (CPU and memory), so it helps if you can understand the basics of how CPUs and memory work.

As I’ve written before, modern (electronic) computers are essentially a bunch of electronic switches. (Earlier in computing history, there were computers with electromechanical switches, too!)

Machine code is basically a bunch of settings for the switches inside the computer. It is extremely tedious and laborious to do programming that way, so people created programming languages to allow programmers to define programs in a more “human” kind of language, along with compilers that translate the programming language into machine language.

2 Likes

Wow. You are really very pedagogical :slight_smile:

1 Like

I’m starting to understand.

What exactly is a compiler. To my infantile brain it seems like a mysterious little person who somehow resides inside my computer, doing the actual work :laughing:

I studied this as well as some explanation I received previously on this site about declaring. I’m starting to get it.

I also saved this

Read write (RW or R/W) vs. read-only (RO):

All this is very helpful and I also saved it to a folder I created called “Answers to Go Questions” where I save all particularly helpful answers that I want to refer to in the future.

I love learning!

2 Likes

Hi Cherolyn,

You are not too far off. People love to anthropomorphize and talk about the compiler with words like, “the so-and-so-construct tells the compiler blah blah blah.”

And before the late 1950s, there were no programming languages or operating systems. People who programmed computers designed algorithms and then figured out how to translate them into machine language programs. The operator of the computer entered the programs manually, or the programs were recorded onto tape or cards with punched holes that the computer could read as 1s and 0s.

Later, programs called compilers were written to automatically translate programming languages (like Fortran and ALGOL) into machine language. Operating systems (another kind of computer program) were written to help automate operating the computer, so the computer could do more things automatically without a human to help it.

So it’s like there is someone reading your program, translating it to machine language, and entering it into the computer and starting it running. But those tasks are now done by the computer itself, not a human. (Also, the people didn’t live inside the computer.)

As late as the 1970s, it was still possible – and sometimes necessary – for a human operator to enter programs manually into a computer. As an example, here is a photo of a PDP-11/70 front panel:

(Click on the link to see the photo of the panel that is at the bottom of the computer.)

Look at the row of switches. Those are used to enter data to be stored in the computer memory and act as a program. The program was entered as 1s and 0s, one word at a time. You would set the switches to a binary digital value, then push another switch to enter it into the computer’s memory. Then the next word, and so on, until the entire program was entered. Then you could press another switch to run the program you entered. See what I mean by “tedious and laborious”? Computers of this type could not do anything by themselves when turned on. They would just sit there waiting for a human to enter a program that told how to load the operating system from a tape or disk drive. When the computer crashed, someone would have to enter the program with the switches, and get every bit correct, then press a button.

So you can be thankful that nowadays there are very nice and sophisticated programming languages and operating systems!

By the way, the real reason I’m telling you all this is so later you can understand pointers more easily. In the photo, notice the rows of indicator lights above the switches, labeled “DATA” and “ADDRESS”. See if you can figure out what those are for.

1 Like

Had an enjoyable time perusing the articles you cited