Tag Info

New answers tagged

-1

A statement in lower-level languages hails from what the CPU can do with one instruction. With something like JavaScript, a statement is what the interpreter can do with one instruction. This may not seem like a particularly human-satisfying answer, but the concept of a statement always comes from the machine's point of view. As programmers, we do have to ...


-1

A statement is a single line of code that ends with a statement terminator which is a semicolon, or a series of single-line statements in a block like being enclosed in {} brackets and may also contain nested blocks.


4

The Wikipedia definition is not abstract or bad at all in my opinion. A statement is an injunction to the machine: int x = 2; // machine, create an integer with value 2! x += 5; // machine, add 5 to that integer! Console.WriteLine(f(x)); // machine, write "f of that integer" to the console! As pointed out in other answers, ...


33

Charles Grant's comparison to a complete sentence is a great way to explain what a statement is to someone who's new to programming. You should start there to give your friend an intuitive sense of what a statement is. It's unsatisfying, though, once you get a little further into the language and learn that there are statements that don't end in a semicolon, ...


1

As mentioned in Charles' answer, the best way I have found to explain the semicolon is that it acts like a period in an English sentence, and then explain all the special cases (like the braces on an if statement, which replace a semicolon) . It is terribly hard to explain why we break things up the way we do, just like how it is hard to explain to a ...


9

The easiest way to explain what a statement is, is comparing it to its opposite: an expression. Expressions evaluate to values, statements don't evaluate to anything. That's the distinguishing characteristic of a statement. For example: 1 is an expression (it evaluates to itself, i.e. 1). But 1; is a statement, it doesn't evaluate to anything. Note ...


2

We stole the word statement from language arts where it is a type of sentence. And when you put the period at the end of a sentence you also put a semicolon at the end of a statement. All sentences convey a complete thought and likewise a statement conveys a complete action. Now some sentences can refer to stuff not in the sentence by using pronouns and ...


48

A statement in a computer language is like a well-formed sentence in a human language. It can be completely parsed by the rules of grammar for the language. Just as a complete sentence in English is terminated with a period (or other punctuation, eg. exclamation mark), in many computer languages a complete statement is terminated by a semi-colon. ...


2

A statement is a piece of code that will tell the application to execute an instruction. The instruction can contain parts that are made up of other instructions (functions, methods, etc.), parameters, and/or comments. These contained instructions are evaluated/executed before the outer instruction. Some languages do not allow for embedding other ...


0

The behavior and semantics of nested functions are much closer to anonymous functions than to non-nested functions. Most likely, they simply wanted the syntax to reflect that difference. However, it wouldn't surprise me to see nested functions in a future update, because I believe the reasons are more cultural than technical. Go was intended as a ...


6

Go's primary design goal is to be simple to learn and simple to use even for sub-mediocre programmers, so if you want to write idiomatic Go the anti-pattern you should avoid the most is the "Clever Code" anti-pattern. As for a good reason to not allow nested functions even though you allow anonymous functions - one of the differences between Python and Go ...


1

Here is a revised version: with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Characters; use Ada.Characters; procedure test is type Two_Dimensional_Char_Array is -- Natural range seems more appropriate array (Natural range <>, Natural range <>) of Character; procedure ...


4

The best practice is to use "constructor" function. While the type can be unconstrained, the actual object has to posses some compile time bounds on size (unless you allocate it on heap). You should create additional function for creating this array. Here is how I modified your code and works just fine (do note that I changed indices to be 1 based, as I ...


0

Every programming language is invented by different mind set, experience and objective, and there is no universal guideline setup for creating a language. So whenever a new language comes up it's their inventor choice to think about best naming/ syntax so this is all up to them what they think is best will add there. For example to add two numbers i will ...


4

What matters about programming languages are the semantics, not the syntax. However, syntax is a vehicle for semantics. It is easy to show that two languages can have incompatible semantics (e.g. unrestricted pointers vs. memory safety, or differences in type systems). Let's focus on the syntax and semantics of variable declarations. When we declare a ...


8

Why cant be a global Standard to do all Simple and Common things? We tried that. The concept was called UNCOL, and the idea was that it would be ported to every architecture in the world, everyone would use it for everything. As you can tell, things didn't work out that way. Why not? Because programming is a complex activity, and there is no single ...



Top 50 recent answers are included